Skip to content

Fix compilation error if PACKED is defined before including FMT#3633

Closed
glebm wants to merge 1 commit into
fmtlib:masterfrom
glebm:fmt-enable-if
Closed

Fix compilation error if PACKED is defined before including FMT#3633
glebm wants to merge 1 commit into
fmtlib:masterfrom
glebm:fmt-enable-if

Conversation

@glebm

@glebm glebm commented Sep 11, 2023

Copy link
Copy Markdown
Contributor

Reduces the chance of conflicts between a macro declaration and the template argument name by using CamelCase (PACKED -> IsPacked)

This improves compatibility with oddball SDKs, such as the 3DS libctru.

Fixes #3632

Reduces the chance of conflicts between a macro declaration and the template argument name by using CamelCase (`PACKED` -> `IsPacked`)

Fixes fmtlib#3632
@vitaut

vitaut commented Sep 11, 2023

Copy link
Copy Markdown
Contributor

Thanks for the PR but this should be fixed in libctru by prefixing the macro. We shouldn't be trying to avoid conflicts with poorly named macros from random third-party libraries. In the meantime you can undefine the problematic macro yourself after including the headers that define it.

@vitaut vitaut closed this Sep 11, 2023
@glebm

glebm commented Sep 11, 2023

Copy link
Copy Markdown
Contributor Author

Philosophically correct but why name a template parameter in all caps? This style is usually used for C macros and enums and doesn't seem consistent with the rest of libfmt anyway

@vitaut

vitaut commented Sep 11, 2023

Copy link
Copy Markdown
Contributor

Non-type template parameters normally follow this style.

@ne-lu

ne-lu commented Apr 17, 2024

Copy link
Copy Markdown

For what it's worth, my company also defines a PACKED macro. It's a fairly common alias for __attribute__((PACKED)), you see it a lot in embedded contexts for example.

Would you be open to changing this parameter name to IS_PACKED? There's already IS_CONSTEXPR in a few places, so it's still consistent.

You're right that it isn't this library's responsibility to ensure that your names don't conflict with other people's macros, but PACKED happens to be a fairly common macro people define, so it could save a lot of headaches for people.

@lapointexavier

Copy link
Copy Markdown

I would like to second that, ‘PACKED’ is also a bit too common and it’s causing headaches trying to upgrade fmt. Would you reconsider @vitaut ? If not we’ll find a solution but it seems like a small lift if this PR is all it takes.

@vitaut

vitaut commented Aug 24, 2025

Copy link
Copy Markdown
Contributor

We don't try to workaround conflicts with poorly written macros unless they are part of system APIs but this particular one is no longer there for other reasons.

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.

Compilation error with Nintendo 3DS homebrew compiler

4 participants