Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function macro is expanded if a preprocessor directive separates it from its arguments. #88

Open
mrolle45 opened this issue Jan 3, 2024 · 0 comments

Comments

@mrolle45
Copy link

mrolle45 commented Jan 3, 2024

The C99 Standard states that a function-like macro can be separated from its argument list by whitespace.
If the macro name on one line is followed by a directive and then the argument list on the next line, the macro name is considered to have no arguments and is therefore not replaced.
pcpp doesn't do this. Instead, it acts as though the macro and its arguments are in adjacent lines and expands the macro.

Example:

#define X(a) (a) + 1
X
#
(3)

Should result in

X

(3)

GCC produces this result.
But pcpp produces

(3) + 1

The reason is that pcpp continues to collect unexpanded tokens until it sees an #include, #define, #endif, or the end of the source file, before expanding what it has collected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant