Skip to content

macOS 11 Fix, master branch (2020.12.26.)

This one thing prevents AnalysisBase from compiling for the x86_64-mac110-clang12-opt platform at the moment. With errors like:

In file included from /Users/krasznaa/ATLAS/projects/analysisbase/athena/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopJetMETCPTools.cxx:19:
In file included from /Users/krasznaa/ATLAS/projects/analysisbase/athena/Reconstruction/Jet/JetUncertainties/JetUncertainties/JetUncertaintiesTool.h:9:
/Users/krasznaa/ATLAS/projects/analysisbase/athena/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyEnum.h:229:9: error: expected identifier
        TRUE  = 1
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach/boolean.h:81:17: note: expanded from macro 'TRUE'
#define TRUE    1
                ^
1 error generated.

Yes, I agree, it's pretty crazy that system headers would define macros for the TRUE and FALSE names, but apparently that's what macOS does... 😕

Since the TRUE and FALSE names inside of a namespace should in principle be fine, I didn't want to rename these. Instead I opted for unsetting these macros, should they be defined.

Note also that clang 12 on macOS 11 is producing a ton of warnings, courtesy of -Wrange-loop-analysis.

https://reviews.llvm.org/D4169

Like:

/Users/krasznaa/ATLAS/projects/analysisbase/athena/Control/AthContainers/Root/debug.cxx:169:17: warning: loop variable 'elt' is always a copy because the range of type 'const std::vector<bool>' does not return a reference [-Wrange-loop-analysis]
  for (const T& elt : x) {
                ^
/Users/krasznaa/ATLAS/projects/analysisbase/athena/Control/AthContainers/Root/debug.cxx:226:3: note: in instantiation of function template specialization 'SGdebug::(anonymous namespace)::convert<bool>' requested here
  CONVERT1 (bool)
  ^
/Users/krasznaa/ATLAS/projects/analysisbase/athena/Control/AthContainers/Root/debug.cxx:213:32: note: expanded from macro 'CONVERT1'
#define CONVERT1(T) CONVERT(T) CONVERT(std::vector<T>)
                               ^
/Users/krasznaa/ATLAS/projects/analysisbase/athena/Control/AthContainers/Root/debug.cxx:212:42: note: expanded from macro 'CONVERT'
#define CONVERT(T) if (ti == &typeid(T)) convert (os, *reinterpret_cast<const T*>(p)); else
                                         ^
/Users/krasznaa/ATLAS/projects/analysisbase/athena/Control/AthContainers/Root/debug.cxx:169:8: note: use non-reference type 'bool'
  for (const T& elt : x) {
       ^~~~~~~~~~~~~~

or:

/Users/krasznaa/ATLAS/projects/analysisbase/athena/Control/AthContainers/Root/AuxTypeRegistry.cxx:422:14: warning: loop variable 'p' is always a copy because the range of type 'SG::AuxTypeRegistry::ti_map_t' (aka 'ConcurrentStrMap<const SG::IAuxTypeVectorFactory *, CxxUtils::SimpleUpdater>') does not return a reference [-Wrange-loop-analysis]
  for (auto& p : m_factories)
             ^
/Users/krasznaa/ATLAS/projects/analysisbase/athena/Control/AthContainers/Root/AuxTypeRegistry.cxx:422:8: note: use non-reference type 'const std::__1::pair<const std::__1::basic_string<char> &, const SG::IAuxTypeVectorFactory *>'
  for (auto& p : m_factories)
       ^~~~~~~~~

@ssnyder, should we turn on this warning for our clang 10 nightlies?

Merge request reports