dk / Prima

prima.eu.org
Other
106 stars 27 forks source link

Compilation with MSVC >= 2015 #66

Closed jddurand closed 1 year ago

jddurand commented 1 year ago

Since these versions of MSVC using a macro to define vsnprintf or snprintf is not allowed:

Running Mkbootstrap for Prima ()
        "C:\cl-perl-5.37.5-32bit\bin\perl.exe" -MExtUtils::Command -e chmod -- 644 "Prima.bs"
        "C:\cl-perl-5.37.5-32bit\bin\perl.exe" -MExtUtils::Command::MM -e cp_nonempty -- Prima.bs blib\arch\auto\Prima\Prima.bs 644
        cl -c  -Iinclude -Iinclude/generic -IC:/cl-perl-5.37.5-32bit/c/include/fribidi -IC:/cl-perl-5.37.5-32bit/site/lib/Prima/codecs/win32/include  /openmp  -nologo -GF -W3 -MD -DWIN32 -D_CONSOLE -DNO_STRICT -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DMULTIPLICITY -DPERL_IMPLICIT_SYS -O1 -Zi -GL -D_CRT_SECURE_NO_WARNINGS /wd4244 /wd4267 /wd4018    -DVERSION=\"1.66\"  -DXS_VERSION=\"1.66\"  "-IC:\cl-perl-5.37.5-32bit\lib\CORE"   -Fdapi/api.pdb api/api.c -Foapi/api.obj
api.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\stdio.h(1422): warning C4005: 'vsnprintf' : redéfinition de macro
C:\Users\jddfr\git\perlbuildwindows-build\.cpan\build\Prima-1.66-0\include\apricot.h(25): note: voir la définition précédente de 'vsnprintf'
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\stdio.h(1424): fatal error C1189: #error:  Macro definition of vsnprintf conflicts with Standard Library function declaration
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX86\x86\cl.EXE"' : code retour '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX86\x86\nmake.EXE"' : code retour '0x2'
Stop.

Origin in MSVC's stdio.h:

    #if defined vsnprintf
        // This definition of vsnprintf will generate "warning C4005: 'vsnprintf': macro
        // redefinition" with a subsequent line indicating where the previous definition
        // of vsnprintf was.  This makes it easier to find where vsnprintf was defined.
        #pragma warning(push, 1)
        #pragma warning(1: 4005) // macro redefinition
        #define vsnprintf Do not define vsnprintf as a macro
        #pragma warning(pop)
        #error Macro definition of vsnprintf conflicts with Standard Library function declaration
    #endif
   ...
    #if defined snprintf
        // This definition of snprintf will generate "warning C4005: 'snprintf': macro
        // redefinition" with a subsequent line indicating where the previous definition
        // of snprintf was.  This makes it easier to find where snprintf was defined.
        #pragma warning(push, 1)
        #pragma warning(1: 4005) // macro redefinition
        #define snprintf Do not define snprintf as a macro
        #pragma warning(pop)
        #error Macro definition of snprintf conflicts with Standard Library function declaration
    #endif
dk commented 1 year ago

I fixed these, but bumped into gdiplus only being compileable as C++, and adding /TP to the command line exploded even more. For this reason I'd recommend switching to strawberry perl, - also because it provides many 3rd party libraries you would need to compile yourself to get Prima useful.

dk commented 1 year ago

Addressed in dcaf866. Still won't compile out of the box because of GDI+, but at least this can be remedied by instructions printed by Makefile.PL when the situation is detected.

jddurand commented 1 year ago

I fixed these, but bumped into gdiplus only being compileable as C++, and adding /TP to the command line exploded even more. For this reason I'd recommend switching to strawberry perl, - also because it provides many 3rd party libraries you would need to compile yourself to get Prima useful.

I have compiled all the dependencies except Xpm, so I expect Prima to work fine on Win32 using cl... Interestingly the test suite is almost perfect, if I think that the very few items that fail are because of Prima I'll open a new issue.

dk commented 1 year ago

Great, let's see how it works out.