int a 1;
adheres to, and whether or not there are modern compilers accepting it?
Regards,
Bujor
>
> Hi everybody. Would anyone know what C standard a statement like:
>
> int a 1;
>
> adheres to, and whether or not there are modern compilers accepting it?
isn't that a syntax error?
--
A. Sinan Unur
as...@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:u...@ftc.gov
> int a 1;
This is not C at all.
You probably meant
int a = 1;
--
-ed- emdel at noos.fr ~]=[o
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
C-library: http://www.dinkumware.com/manuals/reader.aspx
"Mal nommer les choses c'est ajouter du malheur au monde."
-- Albert Camus.
"Emmanuel Delahaye" <emdel...@noos.fr> wrote in message
news:Xns92D9E701FB1...@130.133.1.4...
> In 'comp.lang.c', Bujor D Silaghi <bu...@cs.umd.edu> wrote:
>
> > int a 1;
>
> This is not C at all.
>
> You probably meant
>
> int a = 1;
Judging by the subject line, I think Bujor either meant
int a;
or wanted to know if some random C standard and/or compilers exist that
accept
int a 1;
Unless that's the message the compiler spit out when it saw "int a 1;", in
which case you're dead on. I don't know.
-----= Posted via Newsfeed.Com, Uncensored Usenet News =-----
http://www.newsfeed.com - The #1 Newsgroup Service in the World!
-----== 100,000 Groups! - 19 Servers! - Unlimited Download! =-----
Unless there's a
#define a foo=
somewhere above, that's a syntax error.
-Micah
--
Now available for part-time and full-time permanent or contract
positions in the Sacramento, CA (USA) area (or telecommute). Yes, it's
my real email address.
>> int a 1;
>>
>> adheres to, and whether or not there are modern compilers accepting it?
>
> Unless there's a
>
> #define a foo=
He he! Twitsy!
Not in ANSI/ISO C. (By "ANSI/ISO," of course, I mean
"Arrogant Nitwits Syphilitically Inflamed/Intergalactic
Sniffling Orangutans" -- but that was obvious, surely.)
Compilers that accept this construct without complaint
are not properly described as "modern," but as "clueless."
None. This is the form of initialization that was used in V6 C,
in the mid-1970s. It was replaced with the usual "int a = 1" syntax
before 1980, a decade before the first C standard.
>and whether or not there are modern compilers accepting it?
Any modern compiler must issue "at least one" diagnostic for the
above (providing you have not done #define tricks to replace "a"
with "b =" or some such). Having done so, they are then free to
accept or reject the translation unit.
--
In-Real-Life: Chris Torek, Wind River Systems (BSD engineering)
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W)
Domain: to...@bsdi.com http://67.40.109.61/torek/ (for the moment)
(you probably cannot email me -- spam has effectively killed email)
> Hi everybody. Would anyone know what C standard a statement like:
>
> int a 1;
>
> adheres to,
C99 standard? No.
C89 standard? No.
K&R "standard"? No.
Pre-K&R? Yes.
This form of variable initialization is very ancient. A document from
1974 by Brian W. Kernighan (this is from before Kernighan and Ritchie
published the "The C Programming Language") describing this form is
available here:
< http://www.lysator.liu.se/c/bwk-tutor.html#initialization >
Note that this old version also used reversed assignment operators, i.e.
"x =- y" instead of "x -= y". This was later changed to get away from the
problems with having "x=-5" do the same as "x =- 5" instead of "x = -5"
that most programmers expected.
> and whether or not there are modern compilers accepting it?
I doubt any modern compiler will accept this form.
--
Göran Larsson http://www.mitt-eget.com
Bujor
The first C book ever published, K&R1, describes this feature as an
anachronism.
Beware: the compiler that accepts it may also accept =op as a replacement
for op=, with the "interesting" consequence that i=-1 means i -= 1 and
not i = -1. I was actually bitten by this as a beginner, when using an
old (pre-ANSI) VAX C compiler. The assembly listing clearly showed that
i was decremented and I couldn't understand why. Then, I remembered the
anachronisms section at the end of Appendix A and everything was clear.
Ever since, I always surrounded the binary operators by spaces, to be
sure that my expressions are parsed as intended. Nowadays, I do it
exclusively for readability purposes, the anachronic operators not
being supported by standard C.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Dan...@ifh.de
Yay K&R1!
Since I don't see it online, I'll post K&R's rationale for the change.
-Arthur
<quote>-------------------------------------------------------------
17. Anachronisms
Since C is an evolving language, certain obsolete constructions may be
found in older programs. Although most versions of the compiler support
such anachronisms [--as of 1978--], ultimately they will disappear,
leaving only a portability problem behind.
Earlier versions of C used the form =op instead of op= for assignment
operators. This leads to ambiguities, typified by
x=-1
which actually decrements x since the = and the - are adjacent, but
which might easily be intended to assign -1 to x.
The syntax of initializers has changed: previously, the equals sign the
introduces an initializer was not present, so instead of
int x = 1;
one used
int x 1;
The change was made because the initialization
int f (1+2)
resembles a function declaration closely enough to confuse the compilers.
</quote>------------------------------------------------------------
>
> Hi everybody. Would anyone know what C standard a statement like:
>
> int a 1;
That's an error unless it's expanded to something meaningful by a
preprocessor stunt.