Help building HDF4 with Clang: error: implicit declaration of function 'test_mgr_szip' is invalid in C99

All,

Today I was trying to build HDF4 4.2.15 using clang and ifort on macOS Catalina:

❯ xcodebuild -version
Xcode 12.0.1
Build version 12A7300
❯ clang --version
Apple clang version 12.0.0 (clang-1200.0.32.2)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
❯ ifort -V
Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.3.301 Build 20200925_000000
Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.

And it dies with:

Making install in test
make[4]: Entering directory '/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.17/src/hdf4/hdf/test'
clang -DHAVE_CONFIG_H -I. -I../../hdf/src  -I../../hdf/src -I/Users/mathomp4/installed/MPI/intel-clang-2020.4.301/openmpi-4.0.5/Baselibs/6.0.17/Darwin/include/    -I/Users/mathomp4/installed/MPI/intel-clang-2020.4.301/openmpi-4.0.5/Baselibs/6.0.17/Darwin/include/zlib    -I/Users/mathomp4/installed/MPI/intel-clang-2020.4.301/openmpi-4.0.5/Baselibs/6.0.17/Darwin/include/szlib    -I/Users/mathomp4/installed/MPI/intel-clang-2020.4.301/openmpi-4.0.5/Baselibs/6.0.17/Darwin/include/jpeg    -I/Users/mathomp4/installed/MPI/intel-clang-2020.4.301/openmpi-4.0.5/Baselibs/6.0.17/Darwin/include/hdf5    -I/Users/mathomp4/installed/MPI/intel-clang-2020.4.301/openmpi-4.0.5/Baselibs/6.0.17/Darwin/include/hdf    -I/Users/mathomp4/installed/MPI/intel-clang-2020.4.301/openmpi-4.0.5/Baselibs/6.0.17/Darwin/include/netcdf    -I/Users/mathomp4/installed/MPI/intel-clang-2020.4.301/openmpi-4.0.5/Baselibs/6.0.17/Darwin/include/udunits2    -I/Users/mathomp4/installed/MPI/intel-clang-2020.4.301/openmpi-4.0.5/Baselibs/6.0.17/Darwin/include/gsl    -I/Users/mathomp4/installed/MPI/intel-clang-2020.4.301/openmpi-4.0.5/Baselibs/6.0.17/Darwin/include/antlr   -I/Users/mathomp4/installed/MPI/intel-clang-2020.4.301/openmpi-4.0.5/Baselibs/6.0.17/Darwin/include/zlib -I/Users/mathomp4/installed/MPI/intel-clang-2020.4.301/openmpi-4.0.5/Baselibs/6.0.17/Darwin/include/jpeg -I/Users/mathomp4/installed/MPI/intel-clang-2020.4.301/openmpi-4.0.5/Baselibs/6.0.17/Darwin/include/szlib   -O2 -MT mgr.o -MD -MP -MF .deps/mgr.Tpo -c -o mgr.o mgr.c
mgr.c:4080:5: error: implicit declaration of function 'test_mgr_szip' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    test_mgr_szip();   /* write/read with szip compression */
    ^
mgr.c:4080:5: note: did you mean 'test_mgr_init'?
mgr.c:242:1: note: 'test_mgr_init' declared here
test_mgr_init(void)
^
1 error generated.
make[4]: *** [Makefile:783: mgr.o] Error 1
make[4]: Leaving directory '/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.17/src/hdf4/hdf/test'
make[3]: *** [Makefile:425: install-recursive] Error 1
make[3]: Leaving directory '/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.17/src/hdf4/hdf'
make[2]: *** [Makefile:515: install-recursive] Error 1
make[2]: Leaving directory '/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.17/src/hdf4'
make[1]: *** [GNUmakefile:1181: hdf4.install] Error 2
make[1]: Leaving directory '/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.17/src'
make: *** [GNUmakefile:336: install] Error 2

Now the stupid long include line is due to the fact I’m building HDF4 within a framework of other libraries and I’m not the best at GNU Make. But this has worked in the past. My guess is an update to XCode/Clang has triggered this.

Does anyone know how I might fix/workaround this? In truth, I don’t need HDF4 for most of my work (as my inability to build on Graviton2 showed), so I might try disabling it for now, but this might presage an issue somewhere in the library.

Thanks,
Matt

This isn’t a solution, but I did find a possible workaround…by turning off the error. I passed in -Wno-error=implicit-function-declaration into CFLAGS. (I had to do the same with UDUNITS as well.)