extern methods

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Blue Ocean

    #1

    extern methods

    In standard C, what is the effect of declaring a method extern. In
    what cases should I use this? Programs that I've compiled with more
    than one source files and multiple headers still seem to work even
    when a method in one file calls a method in another, even though I've
    yet to declare any method extern. Why?
  • Artie Gold

    #2
    Re: extern methods

    Blue Ocean wrote:[color=blue]
    > In standard C, what is the effect of declaring a method extern. In
    > what cases should I use this? Programs that I've compiled with more
    > than one source files and multiple headers still seem to work even
    > when a method in one file calls a method in another, even though I've
    > yet to declare any method extern. Why?[/color]

    There are no methods in C; they're *functions*.

    Functions have external linkage by default in C, making the keyword
    redundant.

    HTH,
    --ag

    --
    Artie Gold -- Austin, Texas

    "What they accuse you of -- is what they have planned."

    Comment

    • jacob navia

      #3
      Re: extern methods


      "Blue Ocean" <blueoceanz1@ho tmail.com> a écrit dans le message de
      news:3349b232.0 407041543.36178 bf8@posting.goo gle.com...[color=blue]
      > In standard C, what is the effect of declaring a method extern. In
      > what cases should I use this? Programs that I've compiled with more
      > than one source files and multiple headers still seem to work even
      > when a method in one file calls a method in another, even though I've
      > yet to declare any method extern. Why?[/color]

      Functions are extern by default. "Methods" exist (maybe) in C++
      but not in C. In C "methods" are not associated to a data packet
      and called just "Functions" .

      As you may have noticed, in C functions do not receive an
      implicit object pointer (the "this" argument).

      So they aren't methods. They are by default extern, i.e. visible
      in other modules. If you do not want them to be visible
      you define them as static, like this

      static int myFn(int someArg)
      {}

      This means "myFn" will not be visible outside the current unit.



      Comment

      Working...