"extern inline" in C header file
-
I searched the forum for this specific question and can't find it so here it is. I ran into this "extern inline" syntax in several U-boot C header files. I know the idea about putting extern is to avoid the multiple definition, but the confusing part is the inline part. What happens in my compiler is this... it takes the extern, but not the inline. So during linking, it's looking for that function, and can't find it. Now I normally use inline keyword for C++ header files that is protected by include guard, so the extern is not really useful (especially inlined functions already have definition there). My question is, can someone explain in layman's term how this "extern inline" supposed to work? They seem to be mutually exclusive to me: "extern" keyword means "it's defined somewhere else" and inline means "replace your code with this definition". So I believe my compiler is behaving correctly... Yes, I know I can google into this, but I'm just too lazy to think now :laugh: Thanks!
-
I searched the forum for this specific question and can't find it so here it is. I ran into this "extern inline" syntax in several U-boot C header files. I know the idea about putting extern is to avoid the multiple definition, but the confusing part is the inline part. What happens in my compiler is this... it takes the extern, but not the inline. So during linking, it's looking for that function, and can't find it. Now I normally use inline keyword for C++ header files that is protected by include guard, so the extern is not really useful (especially inlined functions already have definition there). My question is, can someone explain in layman's term how this "extern inline" supposed to work? They seem to be mutually exclusive to me: "extern" keyword means "it's defined somewhere else" and inline means "replace your code with this definition". So I believe my compiler is behaving correctly... Yes, I know I can google into this, but I'm just too lazy to think now :laugh: Thanks!
If the function can be inlined it will be, otherwise it will attempt to link to the function. This means it must exist in source somewhere. One thing to check is if a macro is used to define "extern inline" and can be turned on/off easily.
Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
I searched the forum for this specific question and can't find it so here it is. I ran into this "extern inline" syntax in several U-boot C header files. I know the idea about putting extern is to avoid the multiple definition, but the confusing part is the inline part. What happens in my compiler is this... it takes the extern, but not the inline. So during linking, it's looking for that function, and can't find it. Now I normally use inline keyword for C++ header files that is protected by include guard, so the extern is not really useful (especially inlined functions already have definition there). My question is, can someone explain in layman's term how this "extern inline" supposed to work? They seem to be mutually exclusive to me: "extern" keyword means "it's defined somewhere else" and inline means "replace your code with this definition". So I believe my compiler is behaving correctly... Yes, I know I can google into this, but I'm just too lazy to think now :laugh: Thanks!
crewchill wrote:
an someone explain in layman's term how this "extern inline" supposed to work?
Does this link help? http://www.greenend.org.uk/rjk/2003/03/inline.html[^]
Nibu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com