Mail Archives: djgpp/2002/01/29/12:15:16
[about //-style comments in the DJGPP FAQ, section 8.4]
> You've overlooked the following part of that section:
Ok, found it. It was a footnote on another html-page.
> While admittedly perverse, this little monstrosity was written with the
> sole purpose of demonstrating that C and C++ have quite different semantics
> under certain circumstances. Some people think that C is a proper subset
> of C++; the above example shows that this is _not_ true.
>
> In other words, the // comments are just one example of the differences
> between the two languages.
As // comments are not standard C, but an extension provided by some
compilers, I think the example is not that good. But you are right. I
looked it up, and the C++ FAQ says:
http://www.parashift.com/c++-faq-lite/big-picture.html#[6.10]
[6.10] Is C++ backward compatible with ANSI/ISO C?
Almost.
C++ is as close as possible to compatible with C, but no closer. In
practice, the major difference is that C++ requires prototypes, and that
f() declares a function
that takes no parameters (in C, f() is the same as f(...)).
There are some very subtle differences as well, like sizeof('x') is
equal to sizeof(char) in C++ but is equal to sizeof(int) in C. Also, C++
puts structure "tags" in
the same namespace as other names, whereas C requires an explicit struct
(e.g., the typedef struct Fred Fred; technique still works, but is
redundant in C++).
Regards,
David.
- Raw text -