Bug 31749 - endian.h should define uint16_t, uint32_t, and uint64_t
Summary: endian.h should define uint16_t, uint32_t, and uint64_t
Status: UNCONFIRMED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.39
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-17 04:35 UTC by Collin Funk
Modified: 2024-06-11 19:11 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Collin Funk 2024-05-17 04:35:01 UTC
Hello,

Not sure if it is too soon to care about POSIX revision 8 since it isn't official yet.
The next revision will likely require <endian.h> to define uint16_t, uint32_t, or uint64_t. Optionally, it may make all symbols from <stdint.h> visible [1].

I was writing a Gnulib module using that specification and noticed that glibc doesn't define those types. My system uses glibc 2.39.

Here is a snippet from the test case I was writing for Gnulib. Feel free to use it if it is of any help:

$ cat main.c
#define _GNU_SOURCE 1
#include <endian.h>

static_assert (LITTLE_ENDIAN != BIG_ENDIAN);
static_assert (BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == BIG_ENDIAN);

uint16_t t1;
uint32_t t2;
uint64_t t3;

int
main (void)
{
  return 0;
}
$ gcc -std=c23 main.c 
main.c:8:1: error: unknown type name ‘uint16_t’
    8 | uint16_t t1;
      | ^~~~~~~~
main.c:4:1: note: ‘uint16_t’ is defined in header ‘<stdint.h>’; this is probably fixable by adding ‘#include <stdint.h>’
    3 | #include <endian.h>
  +++ |+#include <stdint.h>
[...]

Thanks!

[1] https://austingroupbugs.net/view.php?id=162