2

I recently installed llvm via brew with brew install llvm, in order to use clang with OpenMP, on Mac OS 10.15.4 Catalina

$ which clang
/usr/local/opt/llvm/bin/clang
$ clang -v
clang version 10.0.0 
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin

It appears I'm getting basic cmath errors when compiling c++ code, e.g.

/usr/local/opt/llvm/bin/../include/c++/v1/cmath:317:9: error: no member named
      'signbit' in the global namespace
using ::signbit;
      ~~^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:318:9: error: no member named
      'fpclassify' in the global namespace
using ::fpclassify;
      ~~^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:319:9: error: no member named
      'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
      ~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: 
      'finite' declared here
extern int finite(double)

This makes me think that certain files are missing, perhaps via Xcode?

Any ideas how to fix this?

EB2127
  • 123

1 Answers1

2

I had the same issue, it seems that cmath fails to include the correct math.h.

After applying this solution , I could get the compilation working just fine, so do:

vim /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath. 

#change '#include<math.h>' to

 #include</Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h> instead of <math.h> in