views:

64

answers:

3
test.c(6) : warning C4013: 'add' undefined; assuming extern returning int

I've encountered many times when an undefined function will report an error,thus stopping the building process.

Why this time just a warning?

+5  A: 

Perhaps you normally code in C++, and this is a C program. C++ is stricter than C; it won't let you call undeclared functions.

Marcelo Cantos
+2  A: 

In C++, attempting to call a function without a valid declaration in scope is an error (whereas C requires the compiler to accept it and make certain assumptions in such a case).

If you have an undefined external at link time (as opposed to compile time), that will also stop the build -- it the linker can't find a definition of a function you've called (or tried to call, anyway), so it can't produce an executable.

Jerry Coffin
+1  A: 

Depending on your compiler, you can instruct it to treat warnings as errors. Although it may be inconvenient, this is often a good thing because the compiler knows more about the details of the code than you do.

In the GNU C suite -Werror is your friend. Offer void in Tuvalu.

msw