I frequently come across C header files that contain extern "C"
guards,
but don't contain any actual functions. For example:
/* b_ptrdiff.h - base type ptrdiff_t definition header */
#ifndef __INCb_ptrdiff_th
#define __INCb_ptrdiff_th
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _PTRDIFF_T
#define _PTRDIFF_T
typedef long ptrdiff_t;
#endif /* _PTRDIFF_T */
#ifdef __cplusplus
}
#endif
#endif /* __INCb_ptrdiff_th */
I know that extern "C"
prevents name mangling on functions, but does it also prevent against other interfacing issues on variable and type declarations?
Is the use of extern "C"
in the example above meaningless in terms of resulting compatibility?
extern "C"
does not "prevent" name mangling. It tells the compiler, among other things, to use C-style name mangling. – Blossom