Skip to content

Fix aliasing _has_include with a custom macro - #261

Open
martis42 wants to merge 1 commit into
boostorg:developfrom
martis42:allow_aliasing_has_include
Open

martis42 wants to merge 1 commit into
boostorg:developfrom
martis42:allow_aliasing_has_include

Conversation

@martis42

Copy link
Copy Markdown

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
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
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!

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