Much of this detail is from C++ books that describe how to make C code compile with a C++ compiler.
Much of it turns out to be differences with "non-ANSI" (classic) C, which should be avoided anyway. They are related to the much stronger type checking available in ANSI C.
For example, in C++:
double Internal::sense (int a, unsigned char *text, Internal &p, ...);becomes:
_sense__8InternaliPUcR8Internalederived from:
_sense__ _name__ 8Internal (namelen) class i int PUc Ptr-Unsigned-char R8Internal Reference (namelen) class e ellipsesso these names can get very long (and quite silly).
Using static functions in C helps to hide function names that may be used in other places.
Function parameters must be defined in the ANSI C style for C++.
Function prototypes should go in header files. They are compulsory for C++ and can be enforced with compilation options in C. (OSF: -warnprotos GNU: -Wstrict-prototypes -Wmissing-prototypes -Wconversion)
C++ allows call-by-reference where C requires the pointer to be passed and explicitly dereferenced when used.
Variable arguments uses <stdarg.h> in C++ and <varargs.h> in C. C++ and ANSI C both require at least one parameter of known type.
Pointers to functions are the same in C++ and ANSI C.
Parameterless functions can (and should) be declared with (void) in both C++ and ANSI C.
const can also be used with pointers and strict prototyping to ensure that the data value is not changed when pointers are pased around. This involves using const twice, for example:
const char *const msg = "string";The first const prevents the value "string" being changed. The second prevents the pointer "msg" being reassigned to point somewhere else.
The big headache with this is that once started, const *must* be used in all function calls. Otherwise somewhere down the line a function withou the "const" will be assumed by the compiler (from its prototype) to be capable of changing the pointer or its value and the call will result in compile-time error.
This can be avoided with a (char *) cast in the function call, but if the function prototypes have const for all unchanged pointers/data, and if there is no cheating going on with casts the results should be much improved type checking of code.
Sadly, a similar replacement of ANSI C macros with C++ inline functions is not available. "inline" is in C++ only.
Could be useful though to mimic the C++ behaviour for data structures, with a "XxxNew" and "XxxDel" function for each one.