Re: extern



>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.
.



Relevant Pages

  • Re: Save a System.Drawing.Color in the db
    ... I know Chris, the thing is WHEN can i do this? ... > int value in the database. ... >> saving/reading Color DataColumns in the db? ...
    (microsoft.public.dotnet.framework)
  • Re: integer promotion and arithmetic conversion
    ... wider unsigned type. ... typical 64-bit machine (32-bit int, ... in part because C99 now has "long long" ... Reading email is like searching for food in the garbage, ...
    (comp.lang.c)
  • Re: Importing from a spreadsheet.
    ... "Chris" wrote: ... There fore, some of the data goes in one table, and some in another, ... > I don't know DDL that well, but I'll give it a shot with a simplified example. ... > Software_Id Int, ...
    (microsoft.public.sqlserver.programming)
  • Re: c equivalence of const_cast?
    ... >conversions that change const-ness are allowed implicitly. ... int main{ ... Reading email is like searching for food in the garbage, ...
    (comp.lang.c)
  • Re: WAV file question
    ... which is more C-language related: The WAV format uses ... int val1, val2; ... Reading email is like searching for food in the garbage, ...
    (comp.lang.c)