Environment Information
- What platform are you using?
- 32 and/or 64 bit?
- What build system are you using?
- Can you provide a sample netCDF file or
C code to recreate the issue?
Summary of Issue
nc_perf does not compile with MSVC, so -DNETCDF_ENABLE_BENCHMARKS=ON cannot
be used on Windows. The sources are POSIX-only by construction: none of the 23
.c files in nc_perf/ contains a single _WIN32 guard, and nearly all of
them use gettimeofday, getrusage, or <unistd.h> directly.
Two specific things block tst_chunks3, which is otherwise a useful portable
benchmark (it exercises contiguous / chunked / compressed access at a
configurable shape):
-
nc_perf/tst_chunks3.c — the TIMING_DECLS / TIMING_START / TIMING_END
macros are built on struct rusage and getrusage(RUSAGE_SELF, ...).
MSVC provides neither, and the <sys/resource.h> include is already behind
HAVE_SYS_RESOURCE_H, so the macros are left without a definition.
-
nc_perf/tst_utils.c — includes <sys/time.h> unconditionally (for
struct timeval, used by nc4_timeval_subtract). tst_chunks3 links this
file, so it fails even if (1) is addressed:
nc_perf\tst_utils.c(18,10): error C1083: Cannot open include file:
'sys/time.h': No such file or directory
The rest of the directory fails the same way, e.g.:
nc_perf\bm_many_atts.c(17,10): error C1083: Cannot open include file: 'sys/time.h'
nc_perf\tst_mem.c(15,10): error C1083: Cannot open include file: 'unistd.h'
nc_perf\bm_file.c(19,10): error C1083: Cannot open include file: 'sys/time.h'
nc_perf\tst_wrf_reads.c(17,10):error C1083: Cannot open include file: 'sys/time.h'
Steps to reproduce the behavior
cmake -S netcdf-c -B build -A x64 -DNETCDF_ENABLE_BENCHMARKS=ON -DENABLE_HDF5=ON
cmake --build build --config Release
Note
I have a PR that addresses (1) and (2) only, which is enough to build and run
tst_chunks3 on Windows; the other nc_perf programs are untouched and remain
POSIX-only. Happy to extend it if you would rather see the whole directory
ported, or to close it if nc_perf is intentionally POSIX-only — in which case
it may be worth skipping add_subdirectory(nc_perf) on WIN32 so that
NETCDF_ENABLE_BENCHMARKS=ON fails early with a clear message instead of
partway through the build.
Environment Information
windows-2025, MSVC 14.51.36231)Ccode to recreate the issue?nc_perfsources reproduce it)Summary of Issue
nc_perfdoes not compile with MSVC, so-DNETCDF_ENABLE_BENCHMARKS=ONcannotbe used on Windows. The sources are POSIX-only by construction: none of the 23
.cfiles innc_perf/contains a single_WIN32guard, and nearly all ofthem use
gettimeofday,getrusage, or<unistd.h>directly.Two specific things block
tst_chunks3, which is otherwise a useful portablebenchmark (it exercises contiguous / chunked / compressed access at a
configurable shape):
nc_perf/tst_chunks3.c— theTIMING_DECLS/TIMING_START/TIMING_ENDmacros are built on
struct rusageandgetrusage(RUSAGE_SELF, ...).MSVC provides neither, and the
<sys/resource.h>include is already behindHAVE_SYS_RESOURCE_H, so the macros are left without a definition.nc_perf/tst_utils.c— includes<sys/time.h>unconditionally (forstruct timeval, used bync4_timeval_subtract).tst_chunks3links thisfile, so it fails even if (1) is addressed:
The rest of the directory fails the same way, e.g.:
Steps to reproduce the behavior
Note
I have a PR that addresses (1) and (2) only, which is enough to build and run
tst_chunks3on Windows; the othernc_perfprograms are untouched and remainPOSIX-only. Happy to extend it if you would rather see the whole directory
ported, or to close it if
nc_perfis intentionally POSIX-only — in which caseit may be worth skipping
add_subdirectory(nc_perf)onWIN32so thatNETCDF_ENABLE_BENCHMARKS=ONfails early with a clear message instead ofpartway through the build.