libgpg-error: 1.50
gcc (GCC) 15.0.0 20240509 (experimental)
as of c23 'nullptr' is a reserved word in C https://en.cppreference.com/w/c/language/nullptr
unfortunately some of the tests of libgpg-error use 'nullptr'
so when i compile with $CFLAGS including -std=gnu23 with a gcc that supports c23 libgpg-error fails to compile
t-printf.c: In function ‘check_fprintf_sf’:
t-printf.c:452:18: error: expected identifier or ‘(’ before ‘nullptr’
452 | volatile char *nullptr = NULL; /* Avoid compiler warning. */
the fix is simple enough: rename nullptr to something else (i used nullptr1)
# diff -Naur libgpg-error-1.50/tests/t-printf.c libgpg-error-fixed/tests/t-printf.c
--- libgpg-error-1.50/tests/t-printf.c 2022-12-16 10:20:45.000000000 -0600
+++ libgpg-error-fixed/tests/t-printf.c 2024-10-17 21:13:09.412058624 -0600
@@ -449,7 +449,7 @@
static void
check_fprintf_sf (void)
{
- volatile char *nullptr = NULL; /* Avoid compiler warning. */
+ volatile char *nullptr1 = NULL; /* Avoid compiler warning. */
struct sfstate_s sfstate = {NULL};
gpgrt_stream_t stream;
const char *expect;
@@ -461,8 +461,8 @@
gpgrt_fprintf_sf (stream, string_filter, &sfstate,
"%s a=%d b=%s c=%d d=%.8s null=%s\n",
- nullptr, 1, "foo\x01 bar", 2,
- "a longer string", nullptr);
+ nullptr1, 1, "foo\x01 bar", 2,
+ "a longer string", nullptr1);
expect = "[==>Niente<==] a=1 b=foo\x01 bar c=2 d=a longer null=(null)\n";
result = stream_to_string (stream);
if (strcmp (result, expect))
@@ -475,7 +475,7 @@
gpgrt_fprintf_sf (stream, string_filter, &sfstate,
"a=%d b=%s c=%d d=%.8s e=%s\n",
- 1, "foo\n bar", 2, nullptr, "");
+ 1, "foo\n bar", 2, nullptr1, "");
expect = "a=1 b=foo\n bar c=2 d=[==>Nien e=\n";
result = stream_to_string (stream);
if (strcmp (result, expect))
this results in a successful compilation/test run.