Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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: 'GetVersionExA': was declared deprecated
error C4996: 'GetVersionExW' was declared deprecated

I got the latest version of sqlite to ensure it hasn't been accounted for, but it has not. I'm not sure what to do about this error. I have made no modifications to the source; I'm simply creating a project and including sqlite.h and sqlite.c. Thanks.

like image 620
Casey Avatar asked Nov 17 '13 14:11

Casey


4 Answers

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

Project Properties > Configuration Properties > C/C++ > General > SDL checks [set to No]
like image 69
dns Avatar answered Nov 15 '22 19:11

dns


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)
like image 40
Abyx Avatar answered Nov 15 '22 19:11

Abyx


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.

like image 3
dash-tom-bang Avatar answered Nov 15 '22 19:11

dash-tom-bang


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).

like image 2
wpfwannabe Avatar answered Nov 15 '22 19:11

wpfwannabe