c++ - Misra warning for include guard -


this regarding misra rule 16-0-2 misra c++ 2008 guidelines

macros shall #define'd or #undef'd in global namespace. 

i understand rule polyspace misra checking tool complains following include guard declared @ beginning of file non-compliant. guess can happen if file included in namespace, not case header file.

what other mistakes in code may cause issue?

#ifndef foo_h #define foo_h  ... code etc ...  #endif 

note : example quoted in misra guidelines is

#ifndef my_hdr #define my_hdr     // compliant   namespace ns {     #define foo   // non- compliant     #undef foo    // non-compliant } #endif 

if header guards placed outside braces (in global namespace), code fine , tool broken. send bug report polyspace.

the rationale behind rule pre-processor directives shouldn't placed inside braces (inside namespace declarations or functions etc) because scope global no matter placed.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -