Skip to content

Remove define const hack in ifparser.h#21297

Merged
guitargeek merged 2 commits intoroot-project:masterfrom
guitargeek:ifparser
Feb 18, 2026
Merged

Remove define const hack in ifparser.h#21297
guitargeek merged 2 commits intoroot-project:masterfrom
guitargeek:ifparser

Conversation

@guitargeek
Copy link
Contributor

Defining const as empty and then including the standard headers after
ifparser.h in ifparser.c results in several compiler errors on my
system when I compile with Clang 21 using the glibc fortify wrappers
(see below).

At this point, I think ROOT is built only with C compilers that support
const so we don't need the hack of defining it as an empty
preprocessor macro anymore.

[275/3601] Building C object misc/rmkdepend/CMakeFiles/rmkdepend.dir/ifparser.c.o
FAILED: [code=1] misc/rmkdepend/CMakeFiles/rmkdepend.dir/ifparser.c.o
/nix/store/habs4w5zka28717s5yys25i7vrd5766b-ccache-4.12.3/bin/ccache /nix/store/6n5r46icm0bl55s9p5z2zgcv93m39r5l-clang-wrapper-21.1.8/bin/clang   -fno-omit-frame-pointer -fcolor-diagnostics -Qunused-arguments -pipe -Wall -W -pthread -O2 -g -DNDEBUG -MD -MT misc/rmkdepend/CMakeFiles/rmkdepend.dir/ifparser.c.o -MF misc/rmkdepend/CMakeFiles/rmkdepend.dir/ifparser.c.o.d -o misc/rmkdepend/CMakeFiles/rmkdepend.dir/ifparser.c.o -c /home/rembserj/code/root/root_src/misc/rmkdepend/ifparser.c
In file included from /home/rembserj/code/root/root_src/misc/rmkdepend/ifparser.c:65:
In file included from /nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/stdlib.h:1165:
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/stdlib.h:38:54: error: pass_object_size attribute only applies to constant pointer arguments
   38 |                  __fortify_clang_overload_arg (char *, __restrict, __resolved)))
      |                                                                    ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/stdlib.h:73:43: error: pass_object_size attribute only applies to constant pointer arguments
   73 |                  __fortify_clang_overload_arg (char *, ,__buf),
      |                                                         ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/stdlib.h:91:55: error: pass_object_size attribute only applies to constant pointer arguments
   91 | __NTH (wctomb (__fortify_clang_overload_arg (char *, ,__s), wchar_t __wchar))
      |                                                       ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/stdlib.h:129:71: error: pass_object_size attribute only applies to constant pointer arguments
  129 | __NTH (mbstowcs (__fortify_clang_overload_arg (wchar_t *, __restrict, __dst),
      |                                                                       ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/stdlib.h:159:68: error: pass_object_size attribute only applies to constant pointer arguments
  159 | __NTH (wcstombs (__fortify_clang_overload_arg (char *, __restrict, __dst),
      |                                                                    ^
In file included from /home/rembserj/code/root/root_src/misc/rmkdepend/ifparser.c:66:
In file included from /nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/string.h:548:
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:77:66: error: pass_object_size attribute only applies to constant pointer arguments
   77 | __NTH (strcpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                  ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:86:66: error: pass_object_size attribute only applies to constant pointer arguments
   86 | __NTH (stpcpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                  ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:96:67: error: pass_object_size attribute only applies to constant pointer arguments
   96 | __NTH (strncpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                   ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:107:56: error: pass_object_size attribute only applies to constant pointer arguments
  107 | __NTH (stpncpy (__fortify_clang_overload_arg (char *, ,__dest),
      |                                                        ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:136:66: error: pass_object_size attribute only applies to constant pointer arguments
  136 | __NTH (strcat (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                  ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:145:67: error: pass_object_size attribute only applies to constant pointer arguments
  145 | __NTH (strncat (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                   ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:161:67: error: pass_object_size attribute only applies to constant pointer arguments
  161 | __NTH (strlcpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                   ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:179:67: error: pass_object_size attribute only applies to constant pointer arguments
  179 | __NTH (strlcat (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                   ^
13 errors generated.

Defining const as empty and then including the standard headers after
`ifparser.h` in `ifparser.c` results in several compiler errors on my
system when I compile with Clang 21 using the glibc fortify wrappers
(see below).

At this point, I think ROOT is built only with C compilers that support
`const` so we don't need the hack of defining it as an empty
preprocessor macro anymore.

```txt
[275/3601] Building C object misc/rmkdepend/CMakeFiles/rmkdepend.dir/ifparser.c.o
FAILED: [code=1] misc/rmkdepend/CMakeFiles/rmkdepend.dir/ifparser.c.o
/nix/store/habs4w5zka28717s5yys25i7vrd5766b-ccache-4.12.3/bin/ccache /nix/store/6n5r46icm0bl55s9p5z2zgcv93m39r5l-clang-wrapper-21.1.8/bin/clang   -fno-omit-frame-pointer -fcolor-diagnostics -Qunused-arguments -pipe -Wall -W -pthread -O2 -g -DNDEBUG -MD -MT misc/rmkdepend/CMakeFiles/rmkdepend.dir/ifparser.c.o -MF misc/rmkdepend/CMakeFiles/rmkdepend.dir/ifparser.c.o.d -o misc/rmkdepend/CMakeFiles/rmkdepend.dir/ifparser.c.o -c /home/rembserj/code/root/root_src/misc/rmkdepend/ifparser.c
In file included from /home/rembserj/code/root/root_src/misc/rmkdepend/ifparser.c:65:
In file included from /nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/stdlib.h:1165:
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/stdlib.h:38:54: error: pass_object_size attribute only applies to constant pointer arguments
   38 |                  __fortify_clang_overload_arg (char *, __restrict, __resolved)))
      |                                                                    ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/stdlib.h:73:43: error: pass_object_size attribute only applies to constant pointer arguments
   73 |                  __fortify_clang_overload_arg (char *, ,__buf),
      |                                                         ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/stdlib.h:91:55: error: pass_object_size attribute only applies to constant pointer arguments
   91 | __NTH (wctomb (__fortify_clang_overload_arg (char *, ,__s), wchar_t __wchar))
      |                                                       ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/stdlib.h:129:71: error: pass_object_size attribute only applies to constant pointer arguments
  129 | __NTH (mbstowcs (__fortify_clang_overload_arg (wchar_t *, __restrict, __dst),
      |                                                                       ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/stdlib.h:159:68: error: pass_object_size attribute only applies to constant pointer arguments
  159 | __NTH (wcstombs (__fortify_clang_overload_arg (char *, __restrict, __dst),
      |                                                                    ^
In file included from /home/rembserj/code/root/root_src/misc/rmkdepend/ifparser.c:66:
In file included from /nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/string.h:548:
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:77:66: error: pass_object_size attribute only applies to constant pointer arguments
   77 | __NTH (strcpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                  ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:86:66: error: pass_object_size attribute only applies to constant pointer arguments
   86 | __NTH (stpcpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                  ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:96:67: error: pass_object_size attribute only applies to constant pointer arguments
   96 | __NTH (strncpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                   ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:107:56: error: pass_object_size attribute only applies to constant pointer arguments
  107 | __NTH (stpncpy (__fortify_clang_overload_arg (char *, ,__dest),
      |                                                        ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:136:66: error: pass_object_size attribute only applies to constant pointer arguments
  136 | __NTH (strcat (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                  ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:145:67: error: pass_object_size attribute only applies to constant pointer arguments
  145 | __NTH (strncat (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                   ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:161:67: error: pass_object_size attribute only applies to constant pointer arguments
  161 | __NTH (strlcpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                   ^
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/bits/string_fortified.h:179:67: error: pass_object_size attribute only applies to constant pointer arguments
  179 | __NTH (strlcat (__fortify_clang_overload_arg (char *, __restrict, __dest),
      |                                                                   ^
13 errors generated.
```
This fixes the followowing compiler warning by using a local `char *`
variable for the `str_end` argument of the `strtol` function, which is
then used to reassign the original `const char * cp` variable:

```txt
[2/427] Building C object misc/rmkdepend/CMakeFiles/rmkdepend.dir/ifparser.c.o
/home/rembserj/code/root/root_src/misc/rmkdepend/ifparser.c:97:23: warning: passing 'const char **' to parameter of type 'char **' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
   97 |    *valp = strtol(cp, &cp, 0);
      |                       ^~~
/nix/store/rwalsamz4246k8f1zzxa54qx7w3fbzdg-glibc-2.42-47-dev/include/stdlib.h:178:22: note: passing argument to parameter '__endptr' here
  178 |                         char **__restrict __endptr, int __base)
      |
```
@guitargeek guitargeek self-assigned this Feb 17, 2026
@guitargeek guitargeek requested a review from dpiparo as a code owner February 17, 2026 10:28
@guitargeek guitargeek changed the title Remove define const hack in ifparser.h Remove define const hack in ifparser.h Feb 17, 2026
@github-actions
Copy link

Test Results

    22 files      22 suites   3d 7h 27m 34s ⏱️
 3 794 tests  3 794 ✅ 0 💤 0 ❌
76 312 runs  76 312 ✅ 0 💤 0 ❌

Results for commit e33d290.

Copy link
Contributor

@silverweed silverweed left a comment

Choose a reason for hiding this comment

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

Nice

@guitargeek guitargeek merged commit 5b911ac into root-project:master Feb 18, 2026
29 of 30 checks passed
@guitargeek guitargeek deleted the ifparser branch February 18, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants