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

Compilation error with Nintendo 3DS homebrew compiler #3632

Closed
glebm opened this issue Sep 11, 2023 · 5 comments
Closed

Compilation error with Nintendo 3DS homebrew compiler #3632

glebm opened this issue Sep 11, 2023 · 5 comments
Labels

Comments

@glebm
Copy link
Contributor

glebm commented Sep 11, 2023

I tried updating fmt to v10.1.1 in DevilutionX (diasurgical/devilutionX#6585) and got an error on one of the oddball platforms.

The platform is Nintendo 3DS homebrew, it uses a GCC 13.2.0-based compiler, and the error is this:

In file included from /root/repo/Source/utils/log.hpp:6,
                 from /root/repo/Source/platform/ctr/sockets.cpp:8:
/root/repo/build/_deps/libfmt-src/include/fmt/core.h:1557:68: error: template argument 1 is invalid
 1557 | template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(PACKED)>
      |                                                                    ^~~~~~
/root/repo/build/_deps/libfmt-src/include/fmt/core.h:286:48: note: in definition of macro 'FMT_ENABLE_IF'
  286 | #  define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0
      |                                                ^~~~~~~~~~~
/root/repo/build/_deps/libfmt-src/include/fmt/core.h:286:59: error: expected identifier before ')' token
  286 | #  define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0
      |                                                           ^
/root/repo/build/_deps/libfmt-src/include/fmt/core.h:1557:54: note: in expansion of macro 'FMT_ENABLE_IF'
 1557 | template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(PACKED)>
      |                                                      ^~~~~~~~~~~~~
/root/repo/build/_deps/libfmt-src/include/fmt/core.h:286:59: error: expected '>' before ')' token
  286 | #  define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0
      |                                                           ^
/root/repo/build/_deps/libfmt-src/include/fmt/core.h:1557:54: note: in expansion of macro 'FMT_ENABLE_IF'
 1557 | template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(PACKED)>
      |                                                      ^~~~~~~~~~~~~
/root/repo/build/_deps/libfmt-src/include/fmt/core.h:286:59: error: expected unqualified-id before ')' token
  286 | #  define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0
      |                                                           ^
/root/repo/build/_deps/libfmt-src/include/fmt/core.h:1557:54: note: in expansion of macro 'FMT_ENABLE_IF'
 1557 | template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(PACKED)>
      |                                                      ^~~~~~~~~~~~~

Failing build: https://app.circleci.com/pipelines/github/diasurgical/devilutionX/18895/workflows/2775b1cd-f0ad-4945-911c-530cfc7aca1d/jobs/116663

I cannot reproduce this error on godbolt. I also don't really understand the error message, the code seems fine to me.
I'd appreciate any thoughts on what this could be.

@glebm
Copy link
Contributor Author

glebm commented Sep 11, 2023

I wonder if this is because of the following macro in 3ds/types.h:

https://github.com/devkitPro/libctru/blob/a4634c02905a824d01feae338d1c472ab5dae1eb/libctru/include/3ds/types.h#L51-L52

@glebm
Copy link
Contributor Author

glebm commented Sep 11, 2023

Yep that's it!
Godbolt: https://godbolt.org/z/1GWe1oGa7

I've filed an issue with the 3DS SDK devkitPro/libctru#530 and also sent a workaround here

glebm added a commit to glebm/fmt that referenced this issue Sep 11, 2023
Reduces the chance of conflicts between a macro declaration and the template argument name by using CamelCase (`PACKED` -> `IsPacked`)

Fixes fmtlib#3632
@TuxSH
Copy link

TuxSH commented Sep 11, 2023

I think there are two different issues here:

  • an external lib using non-namespaced macros
  • this library using a full-uppercase identifier name on something that is neither a macro nor a plain enum (bool PACKED template parameter)

@glebm
Copy link
Contributor Author

glebm commented Sep 11, 2023

Yes, this issue only tracks (2). I filed an issue for (1) with the external lib (devkitPro/libctru#530).

@vitaut
Copy link
Contributor

vitaut commented Sep 11, 2023

Commented on the PR.

@vitaut vitaut closed this as completed Sep 11, 2023
@vitaut vitaut added the invalid label Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants