[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: usage of reserved C++-keyword in cthreads.h



On Wednesday 13 February 2002 21:37, Thomas Bushnell, BSG wrote:
>
> Indeed, there is even a construct in C++, something like
>
> extern "C" {
> }
>
> [pardon me if I've remembered it wrong]
>
> which could even be profitably used for *just this purpose*, and yet,
> it isn't.  
There are some mistakes here: the 'extern "C"' declaration is only a hint to 
the compiler that 
a) it should not apply C++ name-mangling to the function-names. This is used 
to have more than function of the same name, distinguishable by te arguments 
they take. Doing this would screw up the linker, in short.
b) it should expect the function to have the binary interface of a C 
function. The only place where this makes a difference are so-called calling 
conventions, there are various versions of it: pushing the first argument 
first on the stack or last, having the caller clean up the stack afterwards 
or the callee etc.

There is another point you totally leave out: the changes required to the 
header are :
- 'extern "C"' declarations
- not using reserved names as variables (typename, class, template, try, 
throw, catch, public, private, protected, virtual are the ones I can remember 
now, I could try to provide a complete list)
- I saw some casts that C++ refuses for better type-safety
All other changes are only results of the above (name-) changes, the 
implementation never has to compile with C++.

> If the designers of the language lied to you, and said "you
> can just include any C header and it will work", then don't blame the
> authors of those *headers* for the designer's lie.
>
No one ever said so. It is just a known fact about and design goal of C++ to 
be able to compile most legal C-programs and make porting of the rest a piece 
of cake. You will nonetheless end up with still legal and good C programs 
afterwards, everybody does it and no two are complaining.

Refusing to support something that is as wide-spread as C++ and as easy to 
support is not helping anyone.


I personally have just two questions left to you: 
Do you have the power to prevent compatibility to C++ from entering cthreads ?
Assuming yes, will you do so or will you first take a look at the patches ?

Ulrich Eckhardt



Reply to: