On 19 Mar 2006 07:37:12 -0800,
al*****@gmail.com wrote:
Hi,is there a code that can compile in c but not in c++ and does not
use any c++ keywords as identifiers? I suspect using void* works in c
but not in c++. Any suggestions?
void* itself works in C++, but implicit 'down' conversion from it does
not. (Although some of the things you would use cv void* for in C,
like generic lists, might be _better_ done in C++ with templates.)
For a complete (I believe) list of things in C90/95 that don't work or
are different in C++(98) see Annex C.1 of the C++ standard. If you
can't afford the USD18 to buy it from ANSI, there are several draft
versions available in the 'papers' section of the committee website
http://www.open-std.org/jtc1/sc22/wg21/ . You can't rely on these
being exactly correct or the same as the official standard everywhere,
but for answering general questions they are good enough. Be sure to
consider as you read whether there are any features of C++ you think
should be changed, or described (documented) differently, so that your
download counts as part of the standards development process. <G?>
The obvious and most widespread are oldstyle (nonprototype) function
definitions and declarations, and implicit int and implicit function
declaration. There are more obscure ones like:
char x [sizeof('x') - 1]; /* legal on most (not all) C
implementations but never on C++ */
C99 adds a number of features that are not in C++, at least not yet as
far as I have tracked. The big ones that spring to mind: long long
types, literals, operations, and formats; stdint.h, inttypes.h, and
other added formats (z, hh, etc.); complex and imaginary numbers and
operations; designated initializers and compound literals; variable
length arrays and flexible array members (of structs).
- David.Thompson1 at worldnet.att.net