Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C versus C++
#2
I believe you will have to use the MISRA C++, since you compile the C files on a C++ compiler. MISRA-C : 2004 chapter 3.5 explicitly states that it doesn't cover C++ issues.
Because there are some subtle differences between C and C compiled on a C++ compiler. Some examples:

C++ enforces explicit typecasting:
unsigned char* str = malloc(N); /* ok in C but not in C++ */
unsigned char* str = (void*) malloc(N); /* ok in both languages */

C++ doesn't allow file extensions in library headers, while C requires it. #include instead of #include .
C++ defines NULL as 0, while C can define NULL as 0 or (void*)0.
C++ allows // comments while C doesn't.
C++ will create default constructors etc for struct types, while C will not.

And so on.
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)