[comp.lang.c] reserved words or what?

schwartz@gondor.psu.edu (Scott E. Schwartz) (11/14/87)

given:

	main()
	{
		int a,b,signed;

		a = b = signed = 1;
	}

is this legal?   PCC on a vax running 4.3BSD and a Sun running SunOS 3.2
doesn't complain.  Neither does lint (at least on the sun), except to
report that a,b, and signed are set but not used.  On the other hand
GCC doesn't want to see a variable named signed.  Which compiler is
broken?  

Disclaimer:  I don't have a copy of the latest ANSI draft, or even an old
copy of K&R at hand. 


-- Scott Schwartz            schwartz@gondor.psu.edu

gwyn@brl-smoke.ARPA (Doug Gwyn ) (11/14/87)

In article <3086@psuvax1.psu.edu> schwartz@gondor.psu.edu (Scott E. Schwartz) writes:
>		int a,b,signed;
>		a = b = signed = 1;

"signed" is now a C keyword, but it's a fairly recent addition to the
language and therefore is not known to some older C compilers.

Other even newer keywords are "const" and "volatile".

ftw@datacube.UUCP (11/16/87)

schwartz@gondor.psu.edu.UUCP writes:
> given:

> 	main()
> 	{
> 		int a,b,signed;

> 		a = b = signed = 1;
> 	}

> is this legal?   PCC on a vax running 4.3BSD and a Sun running SunOS 3.2
> doesn't complain.  Neither does lint (at least on the sun), except to
> report that a,b, and signed are set but not used.  On the other hand
> GCC doesn't want to see a variable named signed.  Which compiler is
> broken?  

> Disclaimer:  I don't have a copy of the latest ANSI draft, or even an old
> copy of K&R at hand. 


> -- Scott Schwartz            schwartz@gondor.psu.edu

According to dpANS, "signed" is a keyword, and therefore can't be used as
a variable name.  The answer to your question is that the Sun compiler
is "broken".


				Farrell T. Woods 

Datacube Inc. Systems / Software Group	4 Dearborn Rd. Peabody, Ma 01960
VOICE:	617-535-6644;	FAX: (617) 535-5643;  TWX: (710) 347-0125
INTERNET: ftw@datacube.COM
UUCP: {rutgers, ihnp4, mirror}!datacube!ftw

aeusesef@csun.UUCP (sean fagan) (11/16/87)

In article <3086@psuvax1.psu.edu> schwartz@gondor.psu.edu (Scott E. Schwartz) writes:
>given:
>	main()
>	{
>		int a,b,signed;
>
>		a = b = signed = 1;
>	}
[is this legal?  PCC doesn't complain, but gcc does]
>Disclaimer:  I don't have a copy of the latest ANSI draft, or even an old
>copy of K&R at hand. 
The ANSI draft would work better;  gcc is an ANSI C compiler, and ANSI
created a modifier to be the opposite of unsigned, signed.  gcc rightly
complains, and pcc rightly doesn't.
>-- Scott Schwartz            schwartz@gondor.psu.edu

 -----

 Sean Eric Fagan          Office of Computing/Communications Resources
 (213) 852 5742           Suite 2600
 1GTLSEF@CALSTATE.BITNET  5670 Wilshire Boulevard
                          Los Angeles, CA 90036
{litvax, rdlvax, psivax, hplabs, ihnp4}!csun!aeusesef