Pre-processing PC-lint

I have a problem with the difference between lint and gcc preprocessors. Example:

#ifndef PRE
#define PRE HLL_
#endif

#define DECLARE_PROC(a,b) DECLARE_PROC_WITH_SP(a##b)
#define P_DECLARE(a,b) DECLARE_PROC(a,b)
#define DECLARE(a) P_DECLARE(PRE,a)

DECLARE(NODE_1)

I use it like:

#define DECLARE_PROC_WITH_SP(OBJ)          \
struct INFO_s *INFO_##OBJ##_p =            \
  &INFO_defaultNode;                       \
void INFO_registerNode_##OBJ(void)         \
{                                          \
  INFO_registerInf(#OBJ, &INFO_##OBJ##_p); \
}

All is well with gcc. Lint gives the following errors:

nodeLog.c  254  Error 10: Expecting ';'
nodeLog.c  254  Error 10: Expecting ';'
nodeLog.c  254  Error 10: Expecting ','
nodeLog.c  254  Error 26: Expected an expression, found ')'
nodeLog.c  254  Error 144: Non-existent return value for Symbol 'INFO_registerInf(const char *, struct INFO_s **)', compare with line 351, file ...
nodeLog.c  254  Error 10: Expecting '}'

This is the result of the lint preprocessor:

/*lint -save -e506 *//*lint -save -e506 *//*lint -save -e506 *//*lint -save -e506 */ struct INFO_s *INFO_/*lint -save -e506 */ HLL_ /*lint -restore */ NODE_1_p = &INFO_defaultNode;void INFO_registerNode_/*lint -save -e506 */ HLL_ /*lint -restore */ NODE_1(void){ INFO_registerInf("/*lint -save -e506 */HLL_ /*lint -restore */NODE_1", &INFO_/*lint -save -e506 */ HLL_ /*lint -restore */ NODE_1_p); }/*lint -restore *//*lint -restore *//*lint -restore *//*lint -restore */

The problem is here:

   struct INFO_s *INFO_/*lint -save -e506 */ HLL_ /*lint -restore */ NODE_1_p

Some lint preprocessor seems to add spaces.

If I changed:

#ifndef PRE
#define PRE HLL_
#endif

#define DECLARE(a) P_DECLARE(PRE,a)

at

#define DECLARE(a) P_DECLARE(HLL_,a)

everything is getting good:

/*lint -save -e506 *//*lint -save -e506 *//*lint -save -e506 *//*lint -save -e506 */ struct INFO_s *INFO_HLL_NODE_1_p = &INFO_defaultNode;void INFO_registerNode_HLL_NODE_1(void){ INFO_registerInf("HLL_NODE_1", &INFO_HLL_NODE_1_p); }/*lint -restore *//*lint -restore *//*lint -restore *//*lint -restore */

The problem goes away:

struct INFO_s *INFO_HLL_NODE_1_p

How can I avoid this problem?

+4
source share

All Articles