After a hiatus of several years working with JavaScript, Java and other Internet related software I've been looking again at C and C++. I've downloaded some C code from GitHub at the link:
https://github.com/rvong/png-debugger
and got the compiled test code PNGDebugger.exe in the Debug folder to scan through the image file example.png in the test folder and the generate output as given in README.md. I also tried PNGDebugger.exe on a PNG file that I generated, and apparently it worked again without any problems.
After this I installed the free Visual Studio Community version 2019 on my Windows 10 platform, then installed C++ and its various dependencies. With that done I opened an empty C++ console project and copied over the .h and .c files from GitHub. Incidentally, to invoke the C compiler as opposed to the C++ compiler you just make sure that any files with the .cpp extension are changed to .c.
Anyway, Visual Studio flags an error for line 117 of the file readPNG.c downloaded from the link:
https://github.com/rvong/png-debugger/blob/master/readPNG.c
Lines 116 and 117 are:
int crcLen = LEN_CKTYPE + length;
unsigned char crcInput[crcLen];
and by mousing over line 117 the error is "Expression must have a constant value". This and other errors are generated by line 117 when I try and build the application. The rest of the code looks OK.
LEN_CKTYPE has a value of 4 as given in a #define in the file constants.h, and length is defined as long at the beginning of the while loop near the beginning of the function void processPNG(...) in the readPNG.c file.
How is this problem fixed, and how is it that the original code compiled successfully? Perhaps an older version of Visual Studio was used which didn't have a problem.