Skip to main content
GameDev.net gamedev.net
🔒 Locked

inline error

Started by sjdibble Sep 28, 2002 at 11:22 AM 2 replies 250+ views
Original Post
sjdibble
sjdibble
Ok, this is probably just obvious to everyone but why does inline float fmax(float A, float B) { return (A > B ? A : B); } generate an ''Unresolved External'' linker error when float fmax(float A, float B) { return (A > B ? A : B); } does not ! In each case, the header file contains the appropriate prototype and the call is being made from a different unit. Stephen
Hippokrates
Hippokrates
Perhaps you should try to implement the function in the header.
Im Anfang war die Tat...Faust
Brobanx
Brobanx
Regular functions have external linkage (meaning you can declare them in one header, and have the function definition elsewhere), but inline functions (as well as template functions) have INTERNAL linkage, meaning the function definitions must be included in the same files they''re called from (so, they must be defined in the header file, and when you include the header, the function is now defined inside the file the function is being called from).
sjdibble
sjdibble
See, I said it was obvious to everyone

Thanks, that sorted the problem

Stephen

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.