Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation fails on macOS 12 on Apple Silicon with error: implicitly declaring library function 'finite' #24

Open
JohnPritchard opened this issue Apr 1, 2022 · 1 comment

Comments

@JohnPritchard
Copy link

Good morning Emmanuel,

Compilation fails on macOS 12 on Apple Silicon with "error: implicitly declaring library function 'finite'." Full error message below. The solution is apparently simple, "include the header <math.h> or explicitly provide a declaration for 'finite'", but I couldn't make this work, instead if I do:

sed -i -e 's@finite@isfinite@' src/levmar/compiler.h

But this is probably not appropriate as a general solution...

Then it compiles and runs.

:info:build /usr/bin/clang -DHAVE_CONFIG_H -I. -I../.. -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -pipe -Os -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -arch arm64 -MT lm.o -MD -MP -MF .deps/lm.Tpo -c -o lm.o lm.c :info:build In file included from lm.c:81: :info:build ./lm_core.c:206:7: error: implicitly declaring library function 'finite' with type 'int (double)' [-Werror,-Wimplicit-function-declaration] :info:build if(!LM_FINITE(p_eL2)) stop=7; :info:build ^ :info:build ./compiler.h:63:19: note: expanded from macro 'LM_FINITE' :info:build #define LM_FINITE finite // ICC, GCC :info:build ^ :info:build ./lm_core.c:206:7: note: include the header <math.h> or explicitly provide a declaration for 'finite' :info:build ./compiler.h:63:19: note: expanded from macro 'LM_FINITE' :info:build #define LM_FINITE finite // ICC, GCC :info:build ^ :info:build In file included from lmbc.c:84: :info:build ./lmbc_core.c:324:13: error: implicitly declaring library function 'finite' with type 'int (double)' [-Werror,-Wimplicit-function-declaration] :info:build if (!LM_FINITE(fpls)) { :info:build ^ :info:build ./compiler.h:63:19: note: expanded from macro 'LM_FINITE' :info:build #define LM_FINITE finite // ICC, GCC :info:build ^ :info:build ./lmbc_core.c:324:13: note: include the header <math.h> or explicitly provide a declaration for 'finite' :info:build ./compiler.h:63:19: note: expanded from macro 'LM_FINITE' :info:build #define LM_FINITE finite // ICC, GCC :info:build ^ :info:build 1 error generated. :info:build 1 error generated.

Best regards
John

@rmathar
Copy link

rmathar commented Nov 9, 2023

compiler.h uses obsolete macros which will be rejected by more and more compilers. The general solution is to add #include <math.h> in compiler.h and to replace finite by isfinite in the source code as suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants