[cfe-dev] Interact with clang's preprocessor

Neil Booth neil at daikokuya.co.uk
Thu Feb 12 16:00:09 PST 2009


Paolo Bolzoni wrote:-

> dear cfe-list,
> 
> I would like to interface with the clang preprocessor in order to check
> programming-style rules. For instance:
> 
> `Arguments to a function-like macro shall not contain tokens that look
> like preprocessing directives.'
> 
> An example of violation.
> ------->
> #define AB define
> #define C A ## B
> #define macro(X) X
> int define;
> int f() {
>    return macro(C);
> }
> -------<

That doesn't look like a pp directive; there is no '#', and it is
certainly not at the start of a logical line.

	return macro(
#ifdef foo
#endif
	);

would be such an example.

Neil.



More information about the cfe-dev mailing list