fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
20.72k stars 2.49k forks source link

a strange problem #4063

Closed Zorono closed 3 months ago

Zorono commented 3 months ago

somehow fmt has conflicts with AMX SDK (related to Pawn Language : https://github.com/maddinat0r/samp-plugin-sdk)

In file included from /mnt/z/My Projects/Zutils/libs/fmt/include/fmt/format.h:41,
                 from /mnt/z/My Projects/Zutils/src/./pluginutils.h:28,
                 from /mnt/z/My Projects/Zutils/src/pluginutils.cpp:18:
/mnt/z/My Projects/Zutils/libs/legacy-sdk/amx/amx.h:269:47: error: template argument 1 is invalid
  269 |   #define PACKED        __attribute__((packed))
      |                                               ^
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:356:48: note: in definition of macro ‘FMT_ENABLE_IF’
  356 | #  define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0
      |                                                ^~~~~~~~~~~
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:1604:68: note: in expansion of macro ‘PACKED’
 1604 | template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(PACKED)>
      |                                                                    ^~~~~~
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:356:59: error: expected identifier before ‘)’ token
  356 | #  define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0
      |                                                           ^
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:1604:54: note: in expansion of macro ‘FMT_ENABLE_IF’
 1604 | template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(PACKED)>
      |                                                      ^~~~~~~~~~~~~
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:356:59: error: expected ‘>’ before ‘)’ token
  356 | #  define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0
      |                                                           ^
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:1604:54: note: in expansion of macro ‘FMT_ENABLE_IF’
 1604 | template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(PACKED)>
      |                                                      ^~~~~~~~~~~~~
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:356:59: error: expected unqualified-id before ‘)’ token
  356 | #  define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0
      |                                                           ^
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:1604:54: note: in expansion of macro ‘FMT_ENABLE_IF’
 1604 | template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(PACKED)>
      |                                                      ^~~~~~~~~~~~~
/mnt/z/My Projects/Zutils/libs/legacy-sdk/amx/amx.h:269:47: error: template argument 1 is invalid
  269 |   #define PACKED        __attribute__((packed))
      |                                               ^
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:356:48: note: in definition of macro ‘FMT_ENABLE_IF’
  356 | #  define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0
      |                                                ^~~~~~~~~~~
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:1643:69: note: in expansion of macro ‘PACKED’
 1643 | template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(!PACKED)>
      |                                                                     ^~~~~~
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:356:59: error: expected identifier before ‘)’ token
  356 | #  define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0
      |                                                           ^
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:1643:54: note: in expansion of macro ‘FMT_ENABLE_IF’
 1643 | template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(!PACKED)>
      |                                                      ^~~~~~~~~~~~~
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:356:59: error: expected ‘>’ before ‘)’ token
  356 | #  define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0
      |                                                           ^
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:1643:54: note: in expansion of macro ‘FMT_ENABLE_IF’
 1643 | template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(!PACKED)>
      |                                                      ^~~~~~~~~~~~~
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:356:59: error: expected unqualified-id before ‘)’ token
  356 | #  define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0
      |                                                           ^
/mnt/z/My Projects/Zutils/libs/fmt/include/fmt/base.h:1643:54: note: in expansion of macro ‘FMT_ENABLE_IF’
 1643 | template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(!PACKED)>
      |                                                      ^~~~~~~~~~~~~

line pluginutils.h:28 : #include <fmt/format.h> line pluginutils.cpp:18 : #include "./pluginutils.h"

please note that i am using GCC 13 (C++ 20)

vitaut commented 3 months ago

The problem is in amx.h which defines the PACKED macro causing conflict. The fix is to change macro name to something like AMX_PACKED.