Note that there are some explanatory texts on larger screens.

plurals
  1. POundefined reference when calling inline function
    primarykey
    data
    text
    <p>I am getting a really odd error from GCC 4.8.1 with inline functions.</p> <p>I have two near-identical inline functions defined in header files (<code>debug.h</code> and <code>error.h</code>) in <code>src/include/</code>, with the only difference being what they print - one prefixes <code>DEBUG:</code> to the message, and the other <code>%s: error: %s</code> (program name, error message). When defining the functions both inline, and compiling a debug build (so it sets the macro <code>DEBUG=1</code>), I get lots of undefined reference errors:</p> <pre><code>src/main_debug.o gcc -osrc/main_debug.o src/main.c -c -Wall -Wextra -Wpedantic -std=gnu11 -march=native -Og -g -DCC="\"gcc\"" -DCFLAGS="\"-Wall -Wextra -Wpedantic -std=gnu11 -march=native -Og -g\"" -DDEBUG=1 -DBTCWATCH_VERSION="\"0.0.1\"" src/lib/btcapi_debug.o gcc -osrc/lib/btcapi_debug.o src/lib/btcapi.c -c -Wall -Wextra -Wpedantic -std=gnu11 -march=native -Og -g -DCC="\"gcc\"" -DCFLAGS="\"-Wall -Wextra -Wpedantic -std=gnu11 -march=native -Og -g\"" -DDEBUG=1 src/lib/libbtcapi_debug.a ar rc src/lib/libbtcapi_debug.a src/lib/btcapi_debug.o ranlib src/lib/libbtcapi_debug.a src/lib/cmdlineutils_debug.o gcc -o src/lib/cmdlineutils_debug.o src/lib/cmdlineutils.c -c -Wall -Wextra -Wpedantic -std=gnu11 -march=native -Og -g -DCC="\"gcc\"" -DCFLAGS="\"-Wall -Wextra -Wpedantic -std=gnu11 -march=native -Og -g\"" -DDEBUG=1 src/lib/libcmdlineutils_debug.a ar rc src/lib/libcmdlineutils_debug.a src/lib/cmdlineutils_debug.o ranlib src/lib/libcmdlineutils_debug.a debug gcc -obtcwatch-debug src/main_debug.o -Lsrc/lib/ -lbtcapi_debug -lcmdlineutils_debug -lcurl -ljansson src/main_debug.o: In function `main': /home/marcoms/btcwatch/src/main.c:148: undefined reference to `debug' src/main_debug.o:/home/marcoms/btcwatch/src/main.c:185: more undefined references to `debug' follow collect2: error: ld returned 1 exit status make: *** [debug] Error 1 </code></pre> <p>But changing <code>debug()</code>'s definition to <code>static inline</code> removes the errors. But I have never received any errors from <code>error()</code>'s definition, although its defenition is <code>inline</code>, and not <code>static inline</code>.</p> <p>The definitions are all in headers (i.e. not prototyped)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload