devkitPro / libctru

Homebrew development library for Nintendo 3DS/Horizon OS user mode (Arm11)

Home Page:https://libctru.devkitpro.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Global macros clash with other things

glebm opened this issue · comments

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