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

Warning on pragma c++20-compat #942

Closed
jputcu opened this issue Aug 2, 2024 · 6 comments
Closed

Warning on pragma c++20-compat #942

jputcu opened this issue Aug 2, 2024 · 6 comments
Assignees
Labels

Comments

@jputcu
Copy link
Contributor

jputcu commented Aug 2, 2024

Using the latest etl-20.39.0, avr-gcc-7.3 (official microchip) I get many of the following warnings:

C:/Users/joris/.conan2/p/etlb996c63d2f6b8/p/include/etl/private/diagnostic_cxx_20_compat_push.h:38:34: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
   #pragma GCC diagnostic ignored "-Wc++20-compat"
                                  ^~~~~~~~~~~~~~~~
@jwellbelove jwellbelove self-assigned this Aug 2, 2024
@jwellbelove jwellbelove added the bug label Aug 2, 2024
@jputcu
Copy link
Contributor Author

jputcu commented Aug 2, 2024

Apparently this option is only known to gcc>=10.

@jwellbelove
Copy link
Contributor

Can you replace the contents of etl/private/diagnostic_cxx_20_compat_push.h with

#if !defined(__AVR__)
  #if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__)
    #pragma GCC diagnostic push 
    #pragma GCC diagnostic ignored "-Wc++20-compat"
  #endif

  #if defined(__clang__) || defined(__llvm__)
    #pragma clang diagnostic push 
    #pragma clang diagnostic ignored "-Wc++20-compat"
  #endif
#endif

@jputcu
Copy link
Contributor Author

jputcu commented Aug 2, 2024

Warnings are gone now, but I don't know if this is the cleanest solution.
Will this be sufficient for older native compilers? I saw a post on Stackoverflow (https://stackoverflow.com/questions/3378560/how-to-disable-gcc-warnings-for-a-few-lines-of-code) which advises the following: "For most compilers it is often a good idea to check the compiler version before trying to disable it"

I did the test and the following also works:

#if defined(__GNUC__) && (__GNUC__ >= 10) && !defined(__clang__) && !defined(__llvm__)
  #pragma GCC diagnostic push 
  #pragma GCC diagnostic ignored "-Wc++20-compat"
#endif

@jwellbelove
Copy link
Contributor

jwellbelove commented Aug 2, 2024

Yes, that was just a quick test to see it it worked.
I'm leaving for a long weekend away in a couple of hours, so I won't be able to look at this until next Tuesday. If you can come up with an improved solution, then you could always create a PR.

@jputcu
Copy link
Contributor Author

jputcu commented Aug 2, 2024

I'm not in a hurry, enjoy your weekend

jwellbelove pushed a commit that referenced this issue Aug 6, 2024
jwellbelove pushed a commit that referenced this issue Aug 6, 2024
@jwellbelove
Copy link
Contributor

Fixed 20.39.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

2 participants