Remove define const hack in ifparser.h#21297
Merged
guitargeek merged 2 commits intoroot-project:masterfrom Feb 18, 2026
Merged
Conversation
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)
|
```
define const hack in ifparser.hdefine const hack in ifparser.h
Test Results 22 files 22 suites 3d 7h 27m 34s ⏱️ Results for commit e33d290. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defining const as empty and then including the standard headers after
ifparser.hinifparser.cresults in several compiler errors on mysystem 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
constso we don't need the hack of defining it as an emptypreprocessor macro anymore.