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

[C++] Fix clang -Wnewline-eof warning #7711

Merged
merged 3 commits into from
Dec 15, 2022

Conversation

mogemimi
Copy link
Contributor

Building a flatc-generated C++ header with Clang 14 and -Wnewline-eof option produces the following warnings generated by the inclusion of several header files <include/flatbuffers/*.h>:

flatbuffers/include/flatbuffers/allocator.h(68,36): error : no newline at end of file [-Werror,-Wnewline-eof]
flatbuffers/include/flatbuffers/buffer_ref.h(53,37): error : no newline at end of file [-Werror,-Wnewline-eof]
flatbuffers/include/flatbuffers/default_allocator.h(64,44): error : no newline at end of file [-Werror,-Wnewline-eof]
flatbuffers/include/flatbuffers/string.h(64,33): error : no newline at end of file [-Werror,-Wnewline-eof]
flatbuffers/include/flatbuffers/struct.h(53,33): error : no newline at end of file [-Werror,-Wnewline-eof]

This PR adds a newline at eof to avoid the warnings.

@github-actions github-actions bot added the c++ label Dec 12, 2022
@dbaileychess
Copy link
Collaborator

Thanks, can you add this flag to the list here as well? https://github.com/google/flatbuffers/blob/master/CMakeLists.txt#L406

@github-actions github-actions bot added codegen Involving generating code from schema lua labels Dec 13, 2022
@mogemimi
Copy link
Contributor Author

@dbaileychess
Thanks for the review! I have added its flag -Wnewline-eof to the CMakeLists.txt. Also, when building flatbuffers with CMake and the flag, there was several similar warnings in other files, which were additionally fixed.

This pull request is rebased to the latest master branch.

@dbaileychess dbaileychess merged commit 9927747 into google:master Dec 15, 2022
@dbaileychess
Copy link
Collaborator

Thanks!

@mogemimi mogemimi deleted the fix-newline-eof branch December 15, 2022 06:05
sunwen18 pushed a commit to sunwen18/flatbuffers that referenced this pull request Dec 25, 2022
* Fix clang -Wnewline-eof warning

* Enable -Wnewline-eof warning

Co-authored-by: Derek Bailey <derekbailey@google.com>
jochenparm pushed a commit to jochenparm/flatbuffers that referenced this pull request Oct 29, 2024
* Fix clang -Wnewline-eof warning

* Enable -Wnewline-eof warning

Co-authored-by: Derek Bailey <derekbailey@google.com>
jochenparm pushed a commit to jochenparm/flatbuffers that referenced this pull request Oct 29, 2024
* Fix clang -Wnewline-eof warning

* Enable -Wnewline-eof warning

Co-authored-by: Derek Bailey <derekbailey@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ codegen Involving generating code from schema lua
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants