How to detect if C code (which needs ‘extern C’) is compiled in C++

The common practice is not to demand client code wraps your header in extern "C", but to do so conditionally yourself. For instance:

#ifdef __cplusplus
extern "C" {
#endif

  // Header content

#ifdef __cplusplus
}
#endif

That way client code is automatically correct without doing anything beyond including the header.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)