Ancient_Hacker said:
The two most common C compilers, gcc and vc
Nice hair-splitting. When you type "gcc", what compiler do you get?
It depends on the extension on the filename. "gcc tmp.c" compiles C.
"gcc tmp.C" or "gcc "tmp.cc" compiles C++. "gcc -c tmp.adb" compiles
Ada (if that option is installed).
It has since version 3.3, June 2003. We're now in July, 2006, at
version 4.1. Your info is about three years out of date.
I don't think so:
================================
% gcc --version
gcc (GCC) 4.0.2
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% cat tmp.c
int try;
int catch;
% gcc -c tmp.c
% cat tmp.C
int try;
int catch;
% gcc -c tmp.C
tmp.C:1: error: expected unqualified-id before 'try'
tmp.C:2: error: expected unqualified-id before 'catch'
================================
When I compile as C, "try" and "catch" are not treated as keywords.
When I compile as C++, they are. Furthermore, the "C Extensions"
section of the gcc documentation doesn't mention "try", "catch", or
exception handling.
You claim that gcc supports try and catch as an extension when
compiling C. Can you provide a sample program that uses this
extension, and a command line that will compile it?
I'm guessing the same applies to vc.
Nice try, but some of us have VC and don't have to guess and get the
facts right.
I have gcc, and I didn't have to guess to get the fact right. I'm
going to stick with my guess about vc for now.
In any case, the real point as far as this newsgroup is concerned is
that try and catch are not part of the standard C language. Any C
compiler *could* provide them as an extension, as long as it uses a
syntax that doesn't break any strictly conforming C program and/or
provides a conforming mode in which the extension is disabled. gcc
*could* provide try and catch as an extension (it has plenty of other
extensions), but even if it did, any code that used that extension
would not be portable.
(I think lcc-win32, which is not a C++ compiler, does support try and
catch or something similar, so it's certainly possible.)