MathisRosenhauer / libaec

libaec - Adaptive Entropy Coding library
https://gitlab.dkrz.de/k202009/libaec
BSD 2-Clause "Simplified" License
12 stars 9 forks source link

Windows compilation error: cannot allocate an array of constant size 0 #26

Closed hmaarrfk closed 11 months ago

hmaarrfk commented 11 months ago

Hello,

I'm reporting a compilation error we get on windows using vs2019.

Full log attached.

[21/24] Building C object tests\CMakeFiles\check_rsi_block_access.dir\check_rsi_block_access.c.obj
FAILED: tests/CMakeFiles/check_rsi_block_access.dir/check_rsi_block_access.c.obj 
C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\HostX64\x64\cl.exe  /nologo  -I%SRC_DIR%\src\..\include -I%SRC_DIR%\build\src\..\include /DWIN32 /D_WINDOWS /O2 /Ob2 /DNDEBUG -MD /showIncludes /Fotests\CMakeFiles\check_rsi_block_access.dir\check_rsi_block_access.c.obj /Fdtests\CMakeFiles\check_rsi_block_access.dir\ /FS -c %SRC_DIR%\tests\check_rsi_block_access.c
%SRC_DIR%\tests\check_rsi_block_access.c(46): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
%SRC_DIR%\tests\check_rsi_block_access.c(46): note: consider using '%zu' in the format string
%SRC_DIR%\tests\check_rsi_block_access.c(68): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
%SRC_DIR%\tests\check_rsi_block_access.c(68): note: consider using '%zu' in the format string
%SRC_DIR%\tests\check_rsi_block_access.c(94): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
%SRC_DIR%\tests\check_rsi_block_access.c(94): note: consider using '%zu' in the format string
%SRC_DIR%\tests\check_rsi_block_access.c(318): error C2057: expected constant expression
%SRC_DIR%\tests\check_rsi_block_access.c(318): error C2466: cannot allocate an array of constant size 0
%SRC_DIR%\tests\check_rsi_block_access.c(318): error C2133: 'slice_offsets': unknown size
%SRC_DIR%\tests\check_rsi_block_access.c(319): error C2057: expected constant expression
%SRC_DIR%\tests\check_rsi_block_access.c(319): error C2466: cannot allocate an array of constant size 0
%SRC_DIR%\tests\check_rsi_block_access.c(319): error C2133: 'slice_sizes': unknown size
[22/24] Linking C executable tests\check_szcomp.exe
ninja: build stopped: subcommand failed.

36.txt

MathisRosenhauer commented 11 months ago

Mark, thanks for reporting this. @joobog could you please fix this? I added a windows build to github actions in case you don't have a local windows installation.

shahramn commented 11 months ago

VLAs: Why aren't variable-length arrays part of the C++ standard? https://stackoverflow.com/questions/1887097/why-arent-variable-length-arrays-part-of-the-c-standard

MathisRosenhauer commented 11 months ago

Right, and they are optional in C11 so for once, MSVC isn't to blame.