[cfe-dev] C vs. C++: Inconsistent type classifications

Chris Lattner clattner at apple.com
Thu Nov 20 14:56:30 PST 2008


On Nov 20, 2008, at 2:46 PM, Doug Gregor wrote:
> There are several places where C and C++ have different definitions
> for the same type classification terms. For example, "integer types"
> in C include enumeration types, but "integer types" in C++ doesn't
> include enumeration types. On the other hand, "object types" in C
> doesn't include incomplete types, while "object types" in C++ does
> include incomplete types.

Ok

> Personally, I favor following the C++ semantics,

Hehe, big surprise ;-)

> because I find the
> C++ classifications more natural ("integer" type doesn't scream
> "enumeration" for me, and whether or not we've seen a definition for a
> type shouldn't affect what kind of type it is), and of course, in the
> long run, the majority of the code in Clang is going to go toward
> supporting C++.

Is there any case where the C++ definition is less restricted than the  
C version?  If the code ends up being:  "if (isinteger || isenum)"  
then it is clear what it is testing.  In common C/C++ code, there  
should be some comments that explains what is going on.

A fourth (bad) option is to come up with new nomenclature for these  
terms that is independent of C and C++.  This punishes everyone  
equally :)

In the end, I think this change is fine.  Please be very careful to  
preserve the semantics of C and add comments where appropriate.

-Chris




More information about the cfe-dev mailing list