MISRA Discussion Forums
5.5 and groups of preprocessing - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.5 Identifers (https://forum.misra.org.uk/forumdisplay.php?fid=160)
+---- Thread: 5.5 and groups of preprocessing (/showthread.php?tid=1211)



5.5 and groups of preprocessing - lovewar - 03-11-2015

such as
Code:
#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:
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 ?


Re: 5.5 and groups of preprocessing - misra-c - 26-11-2015

Rule 5.5 amplification states that
Quote: name of macros that exist prior to preprocessing
be distinct from
Quote: 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.