>On Dec 9, 9:30 pm, Chris Torek <nos...@torek.netwrote:
>In this case, my crystal ball says that you are using gcc, which
is not a C compiler unless you also use the "-ansi -pedantic" [flags].
In article <87**********************************@l16g2000hsf. googlegroups.com>
vicks <vi*******@gmail.comwrote:
>If i using this switches(-ansi ) then it uses C89/c99 std why am
asking this is because It gives an error when I uses "//" comment!!
This is getting off-topic (there are gcc-specific groups for
gcc-specific questions), but ... there are a bunch of different
switches for various versions of gcc. Depending on which version
of gcc you have, it will support one or more of:
-ansi
-std=c89
-std=gnu89
-std=gnu99
-std=c99
The first two mean the same thing, selecting "C89" (also sometimes
called "C90" or "ANSI C", although technically "ANSI C" should now
refer to C99, as ANSI adopted the C99 standard shortly after that
standard was available). The "-pedantic" flag is required for
actual conformance, but the -std (or -ansi) flag is required to
select the mode before turning on conformance.
C89 does not have "//" comments, hence selecting C89 conformance
makes them become syntax errors, as they should be.
Gcc (any version) does not fully support C99 despite the -std=c99
option. Selecting -std=c99, if you have it at all -- it is not
present in older versions -- gets you "as close as possible" in
that particular version of gcc. Exactly how close depends on
which version of gcc you use.
The various "gnu" standards implement the GNUC languages, which
resemble C fairly closely, but are different in a number of important
ways, including things like allowing "sizeof function" (with the
result always being (size_t)1 in at least some variants of GNUC).
Note that different variants of GNUC support *different* features,
so that using any one particular feature may prevent you from using
another version of gcc on your code. (To avoid being trapped into
particular versions of particular compilers, you can simply avoid
using the extensions. Of course, if the extension does something
you really *want*, you have to choose between "portability" and
"convenience and perhaps even accomplishment".)
--
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.