Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

include <cstdint> explicitly #3005

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rathann
Copy link
Contributor

@rathann rathann commented Jan 18, 2023

Prior to gcc-13 various C++ headers in gcc included <cstdint> even though it was not strictly necessary; this results in the compiler having to parse unnecessary code and thus slows down compilation for everyone.  Those unnecessary #includes of <cstdint> have been removed and applications which need the <cstdint> header file need to explicitly include it.

Without the patch, when compiling with gcc-13 you will get this error:

/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp: In function 'std::string MFX::printCodecId(mfxU32)': /builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:3: error: 'uint8_t' was not declared in this scope
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |   ^~~~~~~
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:29:1: note: 'uint8_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
   28 | #include "mfxloader.h"
  +++ |+#include <cstdint>
   29 |
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:12: error: 'data' was not declared in this scope
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |            ^~~~
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:36: error: 'uint8_t' does not name a type
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |                                    ^~~~~~~
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:36: note: 'uint8_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:43: error: expected '>' before '*' token
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |                                           ^
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:43: error: expected '(' before '*' token
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |                                           ^
      |                                           (
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:44: error: expected primary-expression before '>' token
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |                                            ^
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:50: error: expected ')' before ';' token
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |                                                  ^
      |                                                  )

Fixes issue #2954 .

@rathann rathann force-pushed the issue-2954-gcc-13-include-cstdint-explicitly branch from 750fce1 to 51b95bb Compare January 18, 2023 14:01
@rathann
Copy link
Contributor Author

rathann commented Feb 1, 2023

Near-duplicate of #2998 .

@rathann rathann force-pushed the issue-2954-gcc-13-include-cstdint-explicitly branch from 51b95bb to a4f3770 Compare April 19, 2023 12:43
Prior to gcc-13 various C++ headers in gcc included `<cstdint>` even
though it was not strictly necessary; this results in the compiler
having to parse unnecessary code and thus slows down compilation for
everyone.  Those unnecessary #includes of `<cstdint>` have been removed
and applications which need the `<cstdint>` header file need to
explicitly include it.

Without the patch, when compiling with gcc-13 you will get this error:

```
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp: In function 'std::string MFX::printCodecId(mfxU32)':
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:3: error: 'uint8_t' was not declared in this scope
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |   ^~~~~~~
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:29:1: note: 'uint8_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
   28 | #include "mfxloader.h"
  +++ |+#include <cstdint>
   29 |
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:12: error: 'data' was not declared in this scope
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |            ^~~~
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:36: error: 'uint8_t' does not name a type
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |                                    ^~~~~~~
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:36: note: 'uint8_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:43: error: expected '>' before '*' token
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |                                           ^
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:43: error: expected '(' before '*' token
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |                                           ^
      |                                           (
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:44: error: expected primary-expression before '>' token
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |                                            ^
/builddir/build/BUILD/MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp:60:50: error: expected ')' before ';' token
   60 |   uint8_t* data = reinterpret_cast<uint8_t*>(&id);
      |                                                  ^
      |                                                  )
```

Fixes issue Intel-Media-SDK#2954 .
@rathann rathann requested a review from yefeizhou as a code owner April 19, 2023 12:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant