Compiler is able to find function without matching .h file is updated?-Collection of common programming errors

Undefined functions are not automatically an error; the compiler takes them to have a default prototype, then when your code is finally linked if there is something there of the right name it will be used. However, if the default prototype isn’t what your function actually has, its arguments will be set up wrongly (think hammering a square peg into a round hole); the consequences will be unpredictable.

In most cases you should be telling the compiler to treat such cases as an error. For example, on gcc, add -Wall -Werror to every compile line, or add them to the CFLAGS in a typical Makefile.

Originally posted 2013-11-09 22:57:37.