Skip to content

Generated C++ headers from 24.2 fail to compile with -Wall on Apple clang #13787

@danpat

Description

@danpat

What version of protobuf and what language are you using?

C++ with protobuf 24.2, installed via Homebrew

What operating system (Linux, Windows, ...) and version?

macOS 13.4.1

What runtime / compiler are you using (e.g., python version or gcc version)

$ clang --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)

What did you do?

Code that previously compiled with -Wall is now failing with:

/Users/danpat/test/example.pb.h:677:33: error: extra ';' inside a struct [-Werror,-Wextra-semi]
    PROTOBUF_TSAN_DECLARE_MEMBER;

It looks like the change was introduced with this commit:

33b8c45

When PROTOBUF_TSAN is not defined, PROTOBUF_TSAN_DECLARE_MEMBER is defined as empty, which leaves a standalone ; in the generated headers. This triggers a warning/error on Apple clang via the -Wextra-semi option, which is enabled as part of -Wall. I believe it would also trigger on newer GCC which also supports -Wextra-semi, but I'm not currently using any newer GCC versions and don't have a setup to test it.

What did you expect to see

My code still compiled after updating protobuf

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions