tfussell / xlnt

:bar_chart: Cross-platform user-friendly xlsx library for C++11+
Other
1.49k stars 418 forks source link

Compilation error with GCC in file ..\utils\date.cpp #538

Closed sergioferrari closed 3 years ago

sergioferrari commented 3 years ago

I'm trying to compile the Xlnt library with GCC (10.2.0), but I get the following error: ..\xlnt\source\utils\date.cpp:130:73 error: too many initializers for 'tm' 130 | std::tm tm{0,0,0,day,month -1,year -1900,0,0,0,0, nullptr} Using Visual Studio 2019, all went well I'm on Windows 10 (64 bit)

davidfsol5 commented 3 years ago

The date.cpp was recently changed. I had to revert the change to get XInt to compile. I'm using g++.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0. Visual Studio 2019 works because (if memory serves) it automatically defines _MSC_VER.

image

The standard requires 9 attributes It would be better to change the conditional compilation logic to gate the >9 attribute code to the specific compilers that support the extra attributes, and leave the 9 attribute code as the fall-through case.

gkiryaziev commented 3 years ago

An easier way to solve this problem is to add a define at the beginning of the file.

2021-01-23_120819

For me it works well with mingw64.

mkdir build cd build cmake -DSTATIC=ON -DTESTS=OFF -G "MSYS Makefiles" .. cmake --build . --config Release

2021-01-23_120713

tfussell commented 3 years ago

I didn't consider the usage of GCC with Visual Studio. This should be easy to fix by changing some of the #ifdef guards. I'll fix it soon.

tfussell commented 3 years ago

This should be fixed with 7f51eed1079c7194d9cbbefd9fb7309b44abf073 in the master branch. Please let me know if it doesn't work for you.