Skip to content

Fix aliasing _has_include with a custom macro - #261

Open
martis42 wants to merge 2 commits into
boostorg:developfrom
martis42:allow_aliasing_has_include
Open

martis42 wants to merge 2 commits into
boostorg:developfrom
martis42:allow_aliasing_has_include

Conversation

@martis42

Copy link
Copy Markdown
Contributor

Fixes #260

Disclaimer: This is mostly based on an analysis with an AI Agent.

@martis42
martis42 force-pushed the allow_aliasing_has_include branch from 7babb61 to 9486efc Compare September 21, 2026 17:39
@jefftrull

Copy link
Copy Markdown
Collaborator

From my experiments (and the provided unit test) it looks like this only handles object-like macro aliases for __has_include. I may prefer to hold off for a unified solution.

@martis42

Copy link
Copy Markdown
Contributor Author

You are right, I missed #if defined BUFSIZE and misunderstood your ask for it. Will add a test case for it an look for a proper solution.

@jefftrull

Copy link
Copy Markdown
Collaborator

I'm happy to take on a fix, also.

@martis42

Copy link
Copy Markdown
Contributor Author

You definitely know this code better. My attempt at a logic fix would either way prefer involving an AI Agent.
Did I understand you correctly in #260 (comment) that no further test cases are required, since the same bug is not present for defined?
Then, I think you are better suited to fix this in a more generic way. Feel free to reuse this test case. If I can help you by coming up with other tests, please ping me. I am happy to help insofar I am able to 😀

@jefftrull

Copy link
Copy Markdown
Collaborator

The additional testcase that I think is needed is for function-like macros, i.e.

#define HASINCLUDE(x) __has_include(x)
#if HASINCLUDE(x)
...
#endif

The expansion path is likely to be different than the object-like macros #define HASINCLUDE __has_include.

As for defined() I have convinced myself that the Wave implementation is arguably conforming.

Given that I would have to carefully review any PR for correctness I am happy to write the fix. I will be glad to copy your testcase (and credit you for it). Thanks for the bug report!

@martis42
martis42 force-pushed the allow_aliasing_has_include branch from 9486efc to 666cea7 Compare September 26, 2026 07:22
@martis42

martis42 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor Author

I rebased my test case (numbering conflict with #262) and added the requested extra test case. The tests are now an own commit for easier reuse.

I adapted the fix, which would have been green with the new test case. Just FYI, I know you will go your own way for fixing this. The fix is now an own commit for clear separation allowing you your own appraoch.

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.

Defining an alias to _has_include fails

2 participants