5.5 and groups of preprocessing

Moderators: misra-c, david ward

Post Reply
lovewar
Posts: 10
Joined: Thu Feb 17, 2011 8:01 am
Company: .

5.5 and groups of preprocessing

Post by lovewar » Tue Nov 03, 2015 6:44 am

such as

Code: Select all

#ifndef NO_TAG
static void log (const char *format, ...)
{
}
#else
#if defined(__STDC_VERSION__)
#define log(...) do { } while (0)    // here
#endif
#endif
and, the identifier(log) exists after preprocssing has been performed:

Code: Select all

static void log (const char *format, ...)   // does it apply to #define log ?
{
}
I have a question regarding rule 5.5: does the function(log) apply to #define log ?

misra-c
Posts: 560
Joined: Thu Jan 05, 2006 1:11 pm

Re: 5.5 and groups of preprocessing

Post by misra-c » Thu Nov 26, 2015 10:30 am

Rule 5.5 amplification states that
name of macros that exist prior to preprocessing
be distinct from
identifiers that exist after preprocessing.
Prior to preprocessing there is a macro called "log".

If the code is compiled when NO_TAG is not defined, the code after preprocessing will include a function identifier "log". Under these circumstances, there is a violation of rule 5.5.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “8.5 Identifers”