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

tests/reflection_test.h: add missing <stdint.h> include #7680

Merged
merged 1 commit into from Dec 1, 2022
Merged

tests/reflection_test.h: add missing <stdint.h> include #7680

merged 1 commit into from Dec 1, 2022

Conversation

trofi
Copy link
Contributor

@trofi trofi commented Nov 29, 2022

Without the change build fails on weekly gcc-13 snapshots as:

In file included from /build/flatbuffers/tests/reflection_test.cpp:1:
tests/reflection_test.h:9:57: error: 'uint8_t' has not been declared
    9 | void ReflectionTest(const std::string& tests_data_path, uint8_t *flatbuf, size_t length);
      |                                                         ^~~~~~~

Without the change build fails on weekly `gcc-13` snapshots as:

    In file included from /build/flatbuffers/tests/reflection_test.cpp:1:
    tests/reflection_test.h:9:57: error: 'uint8_t' has not been declared
        9 | void ReflectionTest(const std::string& tests_data_path, uint8_t *flatbuf, size_t length);
          |                                                         ^~~~~~~
@github-actions github-actions bot added the c++ label Nov 29, 2022
@@ -1,6 +1,7 @@
#ifndef TESTS_REFLECTION_TEST_H
#define TESTS_REFLECTION_TEST_H

#include <stdint.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is defined in the C header <stdint.h> which is part of the C++ standard sice 2011, is it necessary to import it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before C++11 you could not reliably include it as it was not a standard header. From C++11 on you can and should include it if you want to pull uint8_t into scope: stdint.h for global scope, <cstdint> for std:: scope. Standard defines the header as https://en.cppreference.com/w/cpp/types/integer

It's still not a fundamental type like int or wchar_t. Those would not require any headers. Standard defines list of fundamental types as https://en.cppreference.com/w/cpp/language/types

@dbaileychess dbaileychess merged commit 7e00b75 into google:master Dec 1, 2022
@trofi trofi deleted the gcc-13-fix branch December 1, 2022 07:46
sunwen18 pushed a commit to sunwen18/flatbuffers that referenced this pull request Dec 25, 2022
Without the change build fails on weekly `gcc-13` snapshots as:

    In file included from /build/flatbuffers/tests/reflection_test.cpp:1:
    tests/reflection_test.h:9:57: error: 'uint8_t' has not been declared
        9 | void ReflectionTest(const std::string& tests_data_path, uint8_t *flatbuf, size_t length);
          |                                                         ^~~~~~~
candhyan pushed a commit to mediaz/flatbuffers that referenced this pull request Jan 2, 2023
Without the change build fails on weekly `gcc-13` snapshots as:

    In file included from /build/flatbuffers/tests/reflection_test.cpp:1:
    tests/reflection_test.h:9:57: error: 'uint8_t' has not been declared
        9 | void ReflectionTest(const std::string& tests_data_path, uint8_t *flatbuf, size_t length);
          |                                                         ^~~~~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants