Skip to content

Conversation

@ceJce
Copy link

@ceJce ceJce commented Jan 14, 2026

Changed so that auto-configured values (without specified values) are set to itself instead of 1.

From issue 14317

isless=islesss

instead of
isless=1

@danmar
Copy link
Owner

danmar commented Jan 14, 2026

I would expect that we test this in some way.

@chrchr-github
Copy link
Collaborator

This needs to be fixed in simplecpp, probably here:
const std::string rhs(eq==std::string::npos ? std::string("1") : macrostr.substr(eq+1));
https://github.com/danmar/simplecpp/blob/6d45cd7bf7f12878ed99a5dcf5ee410ef6492a4a/simplecpp.cpp#L3343

@danmar
Copy link
Owner

danmar commented Jan 14, 2026

This needs to be fixed in simplecpp, probably here:

I am not sure. Then what happens if user executes cppcheck like this:

cppcheck -DX test.c

-DX should work the same as -DX=1 imho.

@ceJce ceJce force-pushed the fix14317_syntax_error branch from 05b5536 to eb9075c Compare January 14, 2026 15:08
@ceJce ceJce marked this pull request as draft January 14, 2026 15:12
@danmar
Copy link
Owner

danmar commented Jan 14, 2026

hmm.. the fix seems to work when I test it quickly. but is in wrong repo.

@ceJce ceJce force-pushed the fix14317_syntax_error branch from eb9075c to 8321b48 Compare January 19, 2026 09:18
@ceJce
Copy link
Author

ceJce commented Jan 19, 2026

This needs to be fixed in simplecpp, probably here: const std::string rhs(eq==std::string::npos ? std::string("1") : macrostr.substr(eq+1)); https://github.com/danmar/simplecpp/blob/6d45cd7bf7f12878ed99a5dcf5ee410ef6492a4a/simplecpp.cpp#L3343

The solution did not work, so I'm working on a new solution.

@ceJce ceJce force-pushed the fix14317_syntax_error branch 3 times, most recently from 852d363 to ca9df18 Compare January 22, 2026 12:22
* Updated so that getConfig extracts ifdefs and if defined as itself, example X=X, and for all else just X
* Updated hasDefine checker to detect configs even in pattern X=X
@ceJce ceJce force-pushed the fix14317_syntax_error branch 3 times, most recently from 1d0fb64 to 2ec411a Compare January 23, 2026 10:23
ceJce added 3 commits January 23, 2026 14:38
* Updated expected results from getConfigs according to defines X=X, else X
* Added two TestPreprocessor tests, getConfigsIssue14317 & getCodeIssue1431, verifying issue 14317 fixed.
…Config.

* Added checks that makes sure that no duplicated of a configuration (like X & X=X, in that case only X is kept) ends up in getConfig ret.
@ceJce ceJce force-pushed the fix14317_syntax_error branch from 2ec411a to 52f76ef Compare January 23, 2026 13:40
@sonarqubecloud
Copy link

"#error abcd\n"
"#endif\n";
ASSERT_EQUALS("\nA\n", getConfigsStr(filedata));
ASSERT_EQUALS("\nA=A\n", getConfigsStr(filedata));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This raises the question, do we want to print A=A when it was just A before? @danmar

Copy link
Owner

@danmar danmar Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is a question. I think it's good to explicitly show that A=A expansion is used. And the "=1" is not wrong to show but it's redundant.

When configuring the defines in the GUI project file dialog, "A;B" means that A and B will be 1. While "A=A;B" would mean that A macro will get value "A" and B macro would get value "1". As far as I know this is how it worked from the beginning.

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.

3 participants