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

Global macros clash with other things #530

Closed
glebm opened this issue Sep 11, 2023 · 0 comments · Fixed by #532
Closed

Global macros clash with other things #530

glebm opened this issue Sep 11, 2023 · 0 comments · Fixed by #532

Comments

@glebm
Copy link
Contributor

glebm commented Sep 11, 2023

Here, libctru defines some macros that can clash with other things:

/// Packs a struct (and other types?) so it won't include padding bytes.
#define PACKED __attribute__((packed))

For example, with the latest version of libfmt, this does not work:

#include <3ds.h>
#include <fmt/core.h>

This is because libfmt uses PACKED as a template parameter name in one of its functions:

https://github.com/fmtlib/fmt/blob/d4987546a4269cc21565ea633eed56db09039d1a/include/fmt/core.h#L1557-L1558

Including things in the opposite order works but really 3ds should not define such macros publicly:

#include <fmt/core.h>
#include <3ds.h>

This can be tricky to work around in a medium size codebase, e.g. diasurgical/devilutionX#6585

glebm added a commit to glebm/libctru that referenced this issue Sep 11, 2023
The prevents compatibility issues with other libraries, such as the one seen in devkitPro#530

Fixes devkitPro#530
glebm added a commit to glebm/libctru that referenced this issue Sep 11, 2023
The prevents compatibility issues with other libraries, such as the one seen in devkitPro#530

Fixes devkitPro#530
glebm added a commit to glebm/libctru that referenced this issue Sep 12, 2023
The mitigates compatibility issues with other libraries, such as the one seen in devkitPro#530.

The `BIT` macro is kept because it is commonly used, so removing it
would be too breaking of a change (see
devkitPro#531 (comment))

Fixes devkitPro#530
glebm added a commit to glebm/libctru that referenced this issue Sep 12, 2023
The mitigates compatibility issues with other libraries, such as the one seen in devkitPro#530.

The `BIT` macro is kept because it is commonly used, so renaming it
would be too breaking of a change (see
devkitPro#531 (comment))

Fixes devkitPro#530
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant