libc_installation unused function
I'm porting zig to OpenBSD right now and following issue came up when compiling the new libc detection.
In libc_installation.cpp:205 the else branch will be taken on posix systems, like OpenBSD. In libc_installation.cpp:271 the branch will also be taken and 3 functions below line libc_installation.cpp:306 will be defined.
Now in libc_installation.cpp:416 the branch will be taken when the plattform is *BSD and the compiler will complain because the 3 functions defined before won't be used.
This is at least how I understand it what causes this error:
/home/jan/src/zig/zig/src/libc_installation.cpp:306:14: error: unused function 'zig_libc_find_native_crt_dir_posix'
[-Werror,-Wunused-function]
static Error zig_libc_find_native_crt_dir_posix(ZigLibCInstallation *self, bool verbose) {
^
/home/jan/src/zig/zig/src/libc_installation.cpp:309:14: error: unused function 'zig_libc_find_native_lib_dir_posix'
[-Werror,-Wunused-function]
static Error zig_libc_find_native_lib_dir_posix(ZigLibCInstallation *self, bool verbose) {
^
/home/jan/src/zig/zig/src/libc_installation.cpp:313:14: error: unused function 'zig_libc_find_native_static_lib_dir_posix'
[-Werror,-Wunused-function]
static Error zig_libc_find_native_static_lib_dir_posix(ZigLibCInstallation *self, bool verbose) {
^
3 errors generated.
I have not looked that much at this specific case, but I guess changing the #if and #else instructions will work.
If the functions are not called because of an ifdef then the same ifdef needs to surround the definition.
From what I can tell the functions shouldn't be called. The path gets set the lines before that. The functions should only be defined when its not a *BSD variant.
The functions should only be defined when its not a *BSD variant.
Sounds good
btw are you aware of #1921?