Talk:Compatibility of C and C++

Legal / valid / conforming
The term "legal" isn't much used in the C++ standard. However, there are a few notable uses in the C compatibility section. See for instance C.1.5 Clause 7: declarations Using these specifiers with type declarations is illegal in C++ "Valid" / "invalid" is widely used in the context "valid C, invalid in C++". The term "conforming program" is only used in C. The corresponding C++ term is "well-formed program". Because of this, I'm changing back to valid/invalid. decltype (talk) 14:44, 9 March 2009 (UTC)
 * To clarify: "Valid" / "invalid" is widely used in the context "valid C, invalid in C++" in the C++ Standard (not just colloquially). For instance:

"E.g., at file scope, is valid in C, invalid in C++"

- C.1.2 Clause 3: basic concepts

Therefore I fail to see why such use would be technically incorrect in the article. decltype (talk) 18:09, 9 March 2009 (UTC)


 * There are around 15 instances of "valid" in the C99 standard.  The problem I have with using these terms is that developers often use valid/invalid when discussing the behavior of the compiler they use, which probably accepts extensions that are not conforming/well-formed C/C++.  By using the terms conforming/well-formed we are calling out the fact that we are referring to what the standard document says, not the behavior of a particular compiler (yes, of course many developers do believe that everything their compiler does is mandated by the standard, but we at least should get it right). Derek farn (talk) 00:44, 10 March 2009 (UTC)

struct, union, or enum declaration in C++ are not first class types
I think that the statement that is found in the section about valid C constructs is misleading, if not wrong. The situation in C++ is just more subtle than it is stated: a struct declaration implies an implicit typedef, if there is no other symbol in identifier scope that inhibits it.

In consequence the code in the next section that is meant to demonstrate this behavior is misleading, too. Indeed, the result for C and C++ is different, as is it done here C refers to the global variable and C++ to the type. But if I put the extern declaration into the function, both refer to the integer variable T in the sizeof operator, since then there is already an identifier T in the scope and the implicit typedef will not trigger. Gustedt (talk) 17:09, 10 September 2010 (UTC)

No implicit conversion from double-pointer to const-double-pointer
With Visual Studio 2008/2010, I realized that you can implicitly convert from int** to const int** when compiling as C (/TC), but not as C++ (/TP). The same is true for volatile. In particular, this code works with the former but not the latter:

int** a;  const int** b = a;

You can see further discussion at the C++ FAQ Lite. Should this be added? – kentyman (talk) 16:38, 1 December 2010 (UTC)


 * Adding. – kentyman (talk) 16:41, 1 December 2010 (UTC)

C allows struct, union, and enum types to be declared in function prototypes, whereas C++ does not.
That it is not true. There is no problem in C++ in declaring or returning a struct,union and enum in a function. — Preceding unsigned comment added by 89.67.175.56 (talk) 23:17, 11 November 2012 (UTC)

C++ cast operators
Wouldn't it be a good idea to use C++ cast operators instead of C-style casts in the C++ examples? --Antred (talk) 15:47, 24 September 2013 (UTC)

External links modified
Hello fellow Wikipedians,

I have just modified 1 one external link on Compatibility of C and C++. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
 * Corrected formatting/usage for http://www.research.att.com/~bs/bs_faq.html#C-is-subset

When you have finished reviewing my changes, please set the checked parameter below to true or failed to let others know (documentation at ).

Cheers.—cyberbot II  Talk to my owner :Online 18:06, 31 March 2016 (UTC)