modelon-community / fmi-library

C library for importing FMUs
Other
111 stars 35 forks source link

Build of minizip fails on macOS with clang12 #11

Open RobertHilbrich opened 3 years ago

RobertHilbrich commented 3 years ago

Hi, GitHub actions recently switched to clang 12 from clang 11, which led to FMIL no longer building for us on macOS. The reason is, that minizip fails to build properly.

Clang 12 build:

#ifdef unix || __APPLE__
            ^
            //
/Users/runner/work/sumo/sumo/fmuChecker/FMIL/ThirdParty/Minizip/minizip/miniunz.c:143:11: error: implicit declaration of function 'mkdir' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    ret = mkdir (dirname,0775);
          ^
/Users/runner/work/sumo/sumo/fmuChecker/FMIL/ThirdParty/Minizip/minizip/miniunz.c:432:25: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                makedir(write_filename);
                        ^~~~~~~~~~~~~~
2 warnings and 1 error generated.

Clang 11 build:

miniunz.c:110:13: warning: extra tokens at end of #ifdef directive [-Wextra-tokens]
#ifdef unix || __APPLE__
            ^
            //
miniunz.c:143:11: warning: implicit declaration of function 'mkdir' is invalid in C99
      [-Wimplicit-function-declaration]
    ret = mkdir (dirname,0775);
          ^
miniunz.c:432:25: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers
      [-Wincompatible-pointer-types-discards-qualifiers]
                makedir(write_filename);
                        ^~~~~~~~~~~~~~
3 warnings generated.

Is there anything you can do to fix this issue? Maybe adding a header file? Like proposed here?

adamjstewart commented 3 years ago

For what it's worth, I added #include <sys/stat.h> to miniunz.c like suggested in that post and the build works for me. Not sure if it works on all systems or with all compilers though. minizip is part of zlib, but I'm not sure how to contribute fixes to zlib.