Error C4996 received when compiling sqlite.c in Visual Studio 2013

后端 未结 5 1614
生来不讨喜
生来不讨喜 2020-12-23 21:49

I ported my project over from Visual Studio 2012 to 2013 and sqlite.c will not compile in it. I\'m receiving this compile-time error:

error C4996: \'GetVersi         


        
相关标签:
5条回答
  • 2020-12-23 22:18

    I had the same issue and I just excluded sqlite3.c and sqlite3.h from project (in Solution Explorer right click on them and select Exclude From Project) and then included again (right click on them again and select Include In Project). And now it works...

    0 讨论(0)
  • 2020-12-23 22:20

    This is because SDL check, try to disable SDL checks:

    Project Properties > Configuration Properties > C/C++ > General > SDL checks [set to No]
    
    0 讨论(0)
  • 2020-12-23 22:27

    I had a similar problem trying to use WTL in a VS 2013 C++ app. Try changing the Platform Toolset in the General page of your project settings to Visual Studio 2013 - Windows XP (v120_xp).

    0 讨论(0)
  • 2020-12-23 22:29

    Better than disabling warnings, you can just disable the relevant code as it is intended to be disabled by adding to the file's preprocessor defines.

    Right-click on sqlite3.c, click Properties, Configuration Properties->C/C++->Preprocessor. Make sure you have "all configurations" selected for the configuration and platform dropdowns (unless you only have one platform, then just select the one that's available) and edit the Preprocessor Definitions to be

    SQLITE_WIN32_GETVERSIONEX=0;%(PreprocessorDefinitions)
    

    This will skip the NTDDI_VERSION check since that symbol isn't defined or is defined incorrectly when your compiler hits sqlite3.c.

    There's this comment in there, too, which may be interesting:

    /*
    ** NOTE: All sub-platforms where the GetVersionEx[AW] functions are
    **       deprecated are always assumed to be based on the NT kernel.
    */
    

    The net effect of setting that #define is that your OS is always assumed to be based on Win NT, which it is since you're Win 8.1 or Win 10 (or greater). ;)

    So basically by disabling that warning you're just making your code slower because it needs to do work to figure out if it's on WinNT or not.

    0 讨论(0)
  • 2020-12-23 22:42

    Actually C4996 is a warning, but sometimes it behaves as an error.
    Anyways, you can just disable it, by using the /wd4996 compiler option, or using the pragma:

    #pragma warning(disable: 4996)
    
    0 讨论(0)
提交回复
热议问题