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

GCC 12 breaking change #116

Closed
sosein opened this issue May 28, 2022 · 2 comments
Closed

GCC 12 breaking change #116

sosein opened this issue May 28, 2022 · 2 comments
Assignees
Labels

Comments

@sosein
Copy link

sosein commented May 28, 2022

When I compile libtcod or my application using it with GCC 12 I get the following error.

/usr/include/libtcod/config.h:84:30: error: standard attributes in middle of decl-specifiers
   84 | #define TCOD_DEPRECATED(msg) [[deprecated(msg)]]
      |                              ^
/usr/include/libtcod/mersenne_types.h:86:9: note: in expansion of macro ‘TCOD_DEPRECATED’
   86 | typedef TCOD_DEPRECATED("This type hides indirection.  Use TCOD_Random* instead.") union TCOD_Random* TCOD_random_t;
      |         ^~~~~~~~~~~~~~~
/usr/include/libtcod/config.h:84:30: note: standard attributes must precede the decl-specifiers to apply to the declaration, or follow them to apply to the type
   84 | #define TCOD_DEPRECATED(msg) [[deprecated(msg)]]
      |                              ^

I believe this is due to a breaking change introduced in GCC 12:

Stricter checking of attributes on friend declarations: if a friend declaration has an attribute, that declaration must be a definition. Moreover, a C++11 attribute cannot appear in the middle of the decl-specifier-seq. (PR99032)

@sosein
Copy link
Author

sosein commented May 28, 2022

Seems like the fix is just changing

typedef TCOD_DEPRECATED("This type hides indirection. Use TCOD_Random* instead.") union TCOD_Random* TCOD_random_t;

to

TCOD_DEPRECATED("This type hides indirection.  Use TCOD_Random* instead.") typedef union TCOD_Random* TCOD_random_t;

@HexDecimal HexDecimal self-assigned this May 28, 2022
@HexDecimal HexDecimal added the bug label May 28, 2022
@HexDecimal
Copy link
Collaborator

Thanks for pointing this out. I didn't know that attributes could apply when put before the typedef keyword until I looked it up just now.

I'll have a quick fix, but it seems the only way to prevent this in the future would be to use GCC 12 in the CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants