c - Why is "symbol lookup error" not caught at compile-time? -
i'm updating old code, , accidentally left macro inside that's no longer defined:
// "detail" not defined anywhere if (detail ("notebook")) { // ... }
the code still compiles , links (its .so library), when loaded get:
gtk3-widget-factory: symbol lookup error: /usr/lib/gtk-3.0/3.0.0/ theming-engines/libmurrine.so: undefined symbol: detail
why isn't caught @ compile time? guess c sees detail
without definition , assumes function int -> int
, right? there way make compiler (gcc) more strict , complain @ compile time? don't think i'm directly using symbols without definition in source or header files.
your analysis correct: detail
treated implicitly-defined function.
from gcc
manual:
-wimplicit-function-declaration (c , objective-c only)
give warning whenever function used before being declared. in c99 mode (
-std=c99
or-std=gnu99
), warning enabled default , made error-pedantic-errors
. warning enabled-wall
.
additionally, @jonathan leffler points out in comments:
also, in versions of gcc, it's error
-werror=implicit-function-declaration
(and other explicit warning option). warnings can converted errors-werror
.
Comments
Post a Comment