From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bf856aff026ed05 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!out02b.usenetserver.com!news.usenetserver.com!in02.usenetserver.com!news.usenetserver.com!news-out.octanews.net!teal.octanews.net!nx01.iad01.newshosting.com!newshosting.com!post02.iad01!roadrunner.com!not-for-mail Newsgroups: comp.lang.ada Subject: Re: C2Ada port to linux updated. References: <1187000082.276474.188160@g12g2000prg.googlegroups.com> <1187066466.723133.18140@z24g2000prh.googlegroups.com> <1187144077.372577.38190@e9g2000prf.googlegroups.com> From: Keith Thompson Organization: None to speak of Date: Tue, 14 Aug 2007 23:40:56 -0700 Message-ID: User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:v74/poTbNibC24fRPDWNqWEx0HE= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 75.80.183.54 X-Complaints-To: abuse@rr.com Xref: g2news2.google.com comp.lang.ada:1448 Date: 2007-08-14T23:40:56-07:00 List-Id: Nasser Abbasi writes: > On Aug 14, 5:01 pm, Keith Thompson wrote: [...] >> That's odd. I just tried a small test program, and gcc versions 3.2 >> and 4.0.0 also support and _Bool. >> >> Here's the test case: >> >> #include >> _Bool obj1; >> bool obj2; >> >> Save it as, say, "foo.c", feed it to "gcc -c", and see what happens. >> Perhaps your gcc is configured and/or installed incorrectly. > > hi Ken; It's Keith. > Yes, the above works, but the c2ada uses typedefs and it includes > _Bool in there, and that is where the problem occur. > > I've just reduced this problem to this simple example to help > illustrate it: > > gcc -c il.h > il.h:5: error: expected identifier before '_Bool' > > > $ cat il.h > > #include > > typedef enum { > _Bool, /* cvt to Boolean, Ada only, unary */ > _UnBool, /* cvt bool->int, Ada only, unary */ > } node_kind_t; [...] gcc is quite correct to reject that. In C99, "_Bool" is a keyword. The code above attempts to use it as an identifier. Some background. There have been two ISO C sntadards, C90 (essentially identical to the ANSI C89 standard) and C99. (There was a minor update in 1995, but we'll ignore that.) Almost all current C compilers fully support C90. Most implement various compiler-specific extensions, but have an option to disable them. Very few compilers implement the full C99 standard, but many compilers implement parts of it. C90 doesn't have a boolean type. C99 added a new type (and keyword) "_Bool", a name chosen to avoid colliding with identifiers in existing code; a new header provides "bool" as an alias for "_Bool". gcc implements _Bool as a keyword. In C, identifiers starting with '_' are reserved to the implementation (the rules are slightly more complex than that), so code outside the standard runtime library shouldn't be using such identifiers in the first place. That's exactly why the C99 standard chose the name _Bool, to avoid breaking valid code. c2ada needs to be fixed so it doesn't use "_Bool" as an identifier, and preferably so it doesn't use any identifiers starting with underscores. Possibly it needs to avoid collisions with identifiers in the C code it processes, but that can be done by prepending some common prefix to each identifier. -- Keith Thompson (The_Other_Keith) kst-u@mib.org San Diego Supercomputer Center <*> "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"