GDI+ library causes “error C2760: syntax error: unexpected token 'identifier', expected 'type specifier'” in VS2017 when compiled for XP

前端 未结 3 1189
南旧
南旧 2021-01-22 01:48

I\'m trying to include the following definitions for GDI+ into my Win32 C++ project that is compiled under Visual Studio 2017:

#include 
#include         


        
3条回答
  •  故里飘歌
    2021-01-22 02:39

    I kinda got it to compile, but this is definitely not a good solution. I'm posting it here as a temp workaround until Microsoft gets their heads out of their ___es. Also if anyone finds a better way, please let me know.

    I basically had to downgrade the entire project to Visual Studio 2015 - Windows XP (v140_xp) just to compile one badly written library:

    This created a problem of its own with the std libraries:

    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cstdio(50): error C4995: 'sprintf': name was marked as #pragma deprecated
    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cstdio(53): error C4995: 'vsprintf': name was marked as #pragma deprecated
    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cstring(20): error C4995: 'strcat': name was marked as #pragma deprecated
    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cstring(21): error C4995: 'strcpy': name was marked as #pragma deprecated
    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cwchar(29): error C4995: 'swprintf': name was marked as #pragma deprecated
    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cwchar(30): error C4995: 'vswprintf': name was marked as #pragma deprecated
    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cwchar(32): error C4995: 'wcscat': name was marked as #pragma deprecated
    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cwchar(34): error C4995: 'wcscpy': name was marked as #pragma deprecated
    

    So I had to shunt those errors of unsafe functions:

    #pragma warning( push )
    #pragma warning( disable: 4995 )
    #include 
    #include 
    #include 
    #pragma warning( pop )
    

    Which is far from ideal!

    (You're basically sacrificing security of the app just to compile that damn GDI+ library.)

提交回复
热议问题