www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/07/08:52:52

Date: Tue, 7 Jul 1998 14:51:18 +0200
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Message-Id: <199807071251.OAA16230@acp3bf.physik.rwth-aachen.de>
To: gss AT writeme DOT com (GiedriusS)
Cc: djgpp AT delorie DOT com
Subject: Re: Q: what's the difference between 'X' and '__X__'?
Newsgroups: comp.os.msdos.djgpp
Organization: RWTH Aachen, III. physikalisches Institut B

In article <01bdaa6b$8b24a8a0$e822b0c2 AT Giedrius DOT omnitel DOT net> you wrote:

> I'm a beginner and I'd like to know what's the difference between,
> for example, 'asm' and '__asm__' or 'volatile' and '__volatile__' etc.?

In ANSI C, the set of keywords is fixed by the ANSI standard. 'asm' is
not one of them, so gcc in ANSI-compatibility mode (gcc -ansi
-pedantic) is not allowed to recognize 'asm' as a keyword. But all
names beginning with a double '_' are reserved to the implementation,
so '__asm__' may be used as a keyword even in this mode.

For 'volatile' the situation is the other way round, I think: 'volatile'
is a new keyword that didn't exist in pre-ANSI C. So 'gcc -traditional'
doesn't recognize it. For similar reasons as above, '__volatile__' is
still available.

So, in a nutshell:

If you want your program to be maximally ANSI compliant, use '__asm__'
and 'volatile'. (But using '__asm__' still obviously means you won't
be able to compile the source on anything but gcc, so you might just
as well use 'asm' right away).

--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019