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

Fix macro expansion and definition over multiple lines #57

Merged
merged 11 commits into from
Dec 24, 2023

Conversation

Laupetin
Copy link
Owner

@Laupetin Laupetin commented Dec 11, 2023

Two things are wrong here which both need to get fixed.

  • Definitions of macros are supposed to be able to span multiple lines when combined with backslash \ at the end of the lines:
#define TestMacro(param0, \
    param1, \
    param2) param0 + param1 - param2
  • Usages of macros with parameters can span multiple lines within their parameter specification, even without using backslashes.
TestMacro(
    1,
    2,
    3
);
  • Commas inside macro parameters are treated as part of the parameter value if they are inside either round parenthesis ( ), square brackets [ ] or curly braces { }
TestMacro((1,1), [2,2], {3,3});

@Laupetin Laupetin changed the title Fix macro expansion multiple lines Fix macro expansion and definition over multiple lines Dec 11, 2023
@Laupetin Laupetin force-pushed the fix/macro-expansion-multiple-lines branch 2 times, most recently from 150ad5e to 89e5c28 Compare December 14, 2023 19:30
@Laupetin Laupetin force-pushed the fix/macro-expansion-multiple-lines branch from 89e5c28 to 9dc7ce2 Compare December 22, 2023 16:41
@Laupetin Laupetin force-pushed the fix/macro-expansion-multiple-lines branch from 885e43d to b1d4176 Compare December 23, 2023 12:54
@Laupetin Laupetin marked this pull request as ready for review December 23, 2023 23:31
@Laupetin Laupetin merged commit 846a9d3 into main Dec 24, 2023
4 checks passed
@Laupetin Laupetin deleted the fix/macro-expansion-multiple-lines branch December 24, 2023 00:11
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

Successfully merging this pull request may close these issues.

Preprocessor does not correctly expand macros with arguments that span multiple lines
1 participant