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

DI fails to build with clang 18.1 #568

Open
zybreak opened this issue Sep 27, 2024 · 5 comments
Open

DI fails to build with clang 18.1 #568

zybreak opened this issue Sep 27, 2024 · 5 comments

Comments

@zybreak
Copy link

zybreak commented Sep 27, 2024

Expected Behavior

di.hpp should not cause compilation failures

Actual Behavior

just including di.hpp causes the compilation to fail
di.hpp:2104:42: error: token is not a valid binary operator in a preprocessor subexpression
di.hpp:2127:42: error: token is not a valid binary operator in a preprocessor subexpression

The offending line(s) are #if (defined(__CLANG__) && __CLANG__ >= 3'9)

It seems clang 18 does not like the 3'9 expression

Steps to Reproduce the Problem

  1. create a empty main function, include di.hpp
  2. compile with clang 18.1

Specifications

  • Version: Clang 18.1
  • Platform: Linux
  • Subsystem: N/A
@zybreak
Copy link
Author

zybreak commented Sep 28, 2024

changing the line to CLANG >= 4 enabled me to compile di.hpp as a temporary workaround for anyone else in the same situation in lieu of a proper fix

@kris-jusiak
Copy link
Collaborator

Hi @zybreak, thank you for reporting the issue. I've been trying to repro it but I think I'm missing something. The following https://godbolt.org/z/7z6x57GeY seems to be okay with clang-18.1. Could you please share godbolt and/or your setup? thanks.

@zybreak
Copy link
Author

zybreak commented Sep 28, 2024

This might be on me, It fails in my project but works when tested in isolation. I'll close this bug report and reopen if I find there is some special case where the above does indeed fail.

Sorry for taking your time

@zybreak zybreak closed this as completed Sep 28, 2024
@kris-jusiak
Copy link
Collaborator

no worries @zybreak , thanks for letting me know and feel free to reopen if needed.

@zybreak zybreak reopened this Sep 29, 2024
@zybreak
Copy link
Author

zybreak commented Sep 29, 2024

Hi again, I had another look at this and I now understand what the problem is.

I got a minimal project up that reproduces this here https://github.com/zybreak/di-test

So the problem is that the code fails when dependency scanning is turned on, which CMake has turned on by default in newer versions for c++20 and above.

I have no real clue as to why the header is interpreted differently when dependency-scanning.

Hope this helps

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

2 participants