Skip to content

[clang-format] Struct/class declaration with export macro treated as initialization in clang-format 19 #94184

@rmarker

Description

@rmarker

In our codebase, we use macros when exporting types for dlls.
This enables conditionally enabling exporting the type, as well as supporting different compilers (e.g. __declspec(dllexport) vs __attribute__ ((dllexport))).

In clang-format 18.1.6 this formats as expected.
E.g. using the default style:

struct EXPORT StructName {};

class EXPORT ClassName {
public:
  ClassName() {}
};

However, testing the latest version of clang-format 19 (f779ec7), the formatting has changed.
It appears that it is instead interpreting it as an initialization.
I.e.

struct EXPORT StructName{};

class EXPORT ClassName{public : ClassName(){}};

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions