Simple C inline linker error

Paragraph 7 of section 6.7.4 says:

Any function with internal linkage can be an inline function. For a function with external linkage, the following restrictions apply: If a function is declared with an inline function specifier, then it shall also be defined in the same translation unit. If all of the file scope declarations for a function in a translation unit include the inline function specifier without extern, then the definition in that translation unit is an inline definition. An inline definition does not provide an external definition for the function, and does not forbid an external definition in another translation unit. An inline definition provides an alternative to an external definition, which a translator may use to implement any call to the function in the same translation unit. It is unspecified whether a call to the function uses the inline definition or the external definition.

Your file does not contain an external definition of addEmUp, and the compiler chose to use the external definition in the call in main.

Provide an external definition, or declare it as static inline.


Try adding the "-O" option to your compiler command. Inlining is turned on only when optimization is enabled.