Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. "extern inline" in C header file

"extern inline" in C header file

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    crewchill
    wrote on last edited by
    #1

    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!

    J N 2 Replies Last reply
    0
    • C crewchill

      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!

      J Offline
      J Offline
      Joe Woodbury
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • C crewchill

        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!

        N Offline
        N Offline
        Nibu babu thomas
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups