Mail Archives: djgpp/2000/04/25/11:14:59
Chris Mears wrote:
>>IMHO it's bad practice to write C that won't compile as C++,
>>but it's certainly possible.
>
>What? Pick a language, and stick with it. C is *not* C++.
But it takes very little effort to ensure that a C program compiles
as C++. Really it's just a question of including a few typecasts
and avoiding giving your variables and functions names like "class",
"public", "private", "new" or "delete". I'm not saying that there
aren't other incompatibilities, just that I haven't seen them in
practice.
The typecasts probably ought to be included for clarity anyway,
and C++ reserved words are surely best avoided, as they are prime
candidates for becoming C reserved words in some future C standard.
(The danger of C++ syntax creeping into C can be seen by the fact
that the latest C standard allows C++ style comments.) A more
immediate reason to avoid them is that C syntax highlighting
software often shows C++ reserved words as reserved even in
C programs. (E.g. RHIDE does this. Or have I just got it set
up wrongly?)
S.
- Raw text -