• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: linking error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: linking error


  • Subject: Re: linking error
  • From: Greg Guerin <email@hidden>
  • Date: Sun, 3 Aug 2008 16:06:55 -0700

Jeffrey Oleander wrote:

I've been programming in C for about 22 years.
That was about the same time I gave up trying
to memorize fine points of every programming
language's standard.  To me, a "static" has
nothing to do with what file it was declared in
but in what program block it was declared, and
that's why the "extern" is necessary to refer
to it from elsewhere.  So, what are we missing?

The keyword 'static' is used in C both for limiting scope, e.g. of functions or variables, and for specifying the storage class of variables. I think this was explained in the original K&R book.


Any variable declared outside a function defaults to the static storage class. Any variable declared inside a function defaults to the auto storage class.

http://www.space.unibe.ch/comp_doc/c_manual/C/CONCEPT/storage_class.html

You also have to use consistent types. So removing the 'static' from 'static char' is only half the problem. The other half of the problem is that a global variable is defined as 'char' in one place, but declared 'extern int' elsewhere.

  -- GG


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: linking error
      • From: Michael <email@hidden>
  • Prev by Date: Re: linking error?
  • Next by Date: Re: Unable to set breakpoints in custom executable
  • Previous by thread: Re: Optimal environment to compile C
  • Next by thread: Re: linking error
  • Index(es):
    • Date
    • Thread