C incompatibilities

suggest change

In rare cases valid C code is not valid C++ code.

Reserved Keywords

The first example are keywords that have a special purpose in C++: the following is legal in C, but not C++.

int class = 5

These errors are easy to fix: just rename the variable.

Weakly typed pointers

In C, pointers can be cast to a void*, which needs an explicit cast in C++. The following is illegal in C++, but legal in C:

void* ptr;
int* intptr = ptr;

Adding an explicit cast makes this work, but can cause further issues.

goto or switch

In C++, you may not skip initialization with goto or switch. The following is valid in C, but not C++:

goto foo;
int skipped = 1;

These bugs may require redesign.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents