zig icon indicating copy to clipboard operation
zig copied to clipboard

libc_installation unused function

Open jan-schreib opened this issue 7 years ago • 4 comments

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.

jan-schreib avatar Feb 26 '19 15:02 jan-schreib

If the functions are not called because of an ifdef then the same ifdef needs to surround the definition.

andrewrk avatar Feb 26 '19 15:02 andrewrk

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.

jan-schreib avatar Feb 26 '19 15:02 jan-schreib

The functions should only be defined when its not a *BSD variant.

Sounds good

andrewrk avatar Feb 26 '19 15:02 andrewrk

btw are you aware of #1921?

andrewrk avatar Feb 27 '19 16:02 andrewrk