Rule 16-0-1 and extern "C"

Moderators: david ward, misra cpp

Post Reply
Posts: 1
Joined: Wed Jul 23, 2008 9:17 am
Company: Miele

Rule 16-0-1 and extern "C"

Post by detra » Thu Jan 14, 2016 8:45 am

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,

Posts: 117
Joined: Wed Apr 27, 2016 2:33 pm
Company: Elektrobit Automotive GmbH

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

Post by dg1980 » Thu Apr 28, 2016 10:17 am

Probably a bit late (i just registered), but the best way to do this is: ... s-personal

misra cpp
Posts: 157
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

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

Post by misra cpp » Tue Oct 11, 2016 11:13 am

This is non-compliant and requires a deviation
Posted by and on behalf of
the MISRA C++ Working Group

Post Reply

Return to “6.16 Preprocessing directives (C++)”