Page 1 of 1

Rule 16-0-1 and extern "C"

Posted: Thu Jan 14, 2016 8:45 am
by detra
Hello,
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?

Code: Select all

#ifndef _MYHEADER_
#define _MYHEADER_

extern "C"
{
    #include "firstheader.h"                // MISRA 16-0-1 violation
}
Thank you for help,
Stefan

Re: Rule 16-0-1 and extern "C"

Posted: Thu Apr 28, 2016 10:17 am
by dg1980
Probably a bit late (i just registered), but the best way to do this is: https://isocpp.org/wiki/faq/mixing-c-an ... s-personal

Re: Rule 16-0-1 and extern "C"

Posted: Tue Oct 11, 2016 11:13 am
by misra cpp
This is non-compliant and requires a deviation