MISRA Discussion Forums

Full Version: Rule 16-0-1 and extern "C"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
if we want to use the same Header files for "C" and "C++" we must use the "extern C" constuct. But the "extern C" construct must be placed before the include of the Header and so our tool reports a MISRA 16-0-1 violation. Is this violation valid? And if so, is there an other solution?

#ifndef _MYHEADER_
#define _MYHEADER_

extern "C"
    #include "firstheader.h"                // MISRA 16-0-1 violation

Thank you for help,
Probably a bit late (i just registered), but the best way to do this is: https://isocpp.org/wiki/faq/mixing-c-and...s-personal
This is non-compliant and requires a deviation