Q:

How can I include a non-system C header file in my C++ code?

0

How can I include a non-system C header file in my C++ code?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Answer : 

If you are including a C header file that isn’t provided by the system, you may need to wrap the #include line in an extern “C” { /*…*/ } construct. This tells the C++ compiler that the functions declared in the header file are C functions.

// This is C++ code
extern "C" {
    // Get declaration for f(int i, char c, float x)
#include "my-C-code.h"
}
int main()
{
    f(7, 'x', 3.14);   // Note: nothing unusual in the call
    // ...
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Interview Questions For Experienced

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
What is the effect of extern “C” in C++?... >>
<< Can we combine C and C++ code?...