Bug 31749

Summary: endian.h should define uint16_t, uint32_t, and uint64_t
Product: glibc Reporter: Collin Funk <collin.funk1>
Component: libcAssignee: Not yet assigned to anyone <unassigned>
Status: UNCONFIRMED ---    
Severity: normal CC: bruno, drepper.fsp, fweimer
Priority: P2 Flags: fweimer: security-
Version: 2.39   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

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