Re: extern
- From: Chris Torek <nospam@xxxxxxxxx>
- Date: 21 Jul 2005 04:38:59 GMT
>Chris Torek wrote:
>> C compilers on Unix-like systems never use the def/ref model ...
In article <o243r2xd21.ln2@xxxxxxxxxxxxxxxxxxxxxxxxx>
Flash Gordon <spam@xxxxxxxxxxxxxxxxxx> wrote:
>Not true, Chris. If you give gcc the correct command line options on a
>Unixlike implementation (Linux) it will not use the common model and
>*will* generate an error on linking if a variable is declared twice even
>with neither declaration specifying an initialiser.
OK, make that "never use def/ref by default." :-)
The (ancient, way-before-C89) C compiler that really annoyed me
was Whitesmiths C for the Z80, which treated:
int a;
and
extern int a;
as meaning exactly the same thing: "a" was "ref"d but not "def"d.
You *had* to write:
int a = 0;
to get the variable defined. During the winter holiday between
1981 and 1982, I did a consulting job, porting a Votrax text-to-speech
program from PL/M to C, using this compiler. I spent about a day
trying to figure out why some variables were undefined, and others
were defined, when they were all carefully defined exactly once,
and "extern"ed everywhere else. It turned out Whitesmiths C did
not even implement the K&R White-book language.
(I ended up creating a source file consisting of:
int switch_a = 0;
char *option_b = NULL;
and so on, for all the variables that were otherwise uninitialized.)
(The library also lacked most of the usual functions, such as
printf(). Fortunately printf() was not a lot of use in this
particular freestanding system, since the point was to speak for
a blind programmer, not print on a screen.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
.
- References:
- extern
- From: DevarajA
- Re: extern
- From: DevarajA
- Re: extern
- From: Chris Torek
- Re: extern
- From: Flash Gordon
- extern
- Prev by Date: Re: List of all functions in a C files
- Next by Date: Re: fork problem
- Previous by thread: Re: extern
- Next by thread: Re: extern
- Index(es):
Relevant Pages
|