Home
Support

Knowledge Base

BSPs and drivers
Community resources
Product documentation
Questions?
Contact us

Trouble #including C headers into C++ code
 
________________________________________________________________________

Applicable Environment
________________________________________________________________________
  • Topic: Trouble #including C headers into C++ code
  • SDP: 6.3.2
  • Target: Any supported target
________________________________________________________________________

Solution
________________________________________________________________________

If you are trying to #include C header files into C++ code, and using code such as the following:

extern "C" {
#include "libavcodec/avcodec.h>"
#include "libavformat/avformat.h"
}

You may see errors such as:

C:/QNX632/target/qnx6/usr/include/math.h:139: error: template with C linkage

This is occurring because the QNX standard headers frequently have extern "C" ifdef'd in if being compiled as C++. The extern "C" cannot be nested.

The solution is to #include the standard C header that is giving the error, e.g. math.h, before the extern "C".

________________________________________________________________________
NOTE: This entry has been validated against the SDP version listed above. Use caution when considering this advice for any other SDP version. For supported releases, please reach out to QNX Technical Support if you have any questions/concerns.
________________________________________________________________________


Related Attachments
 None Found





Please contact us with your questions or concerns.