nursmaul nursmaul - 28 days ago 14
C++ Question

No support for VS2015 in OpenGL GLI?

I am trying to use 'OpenGL Image' library( http://gli.g-truc.net/0.8.1/index.html )( abbreviated as GLI, like GLM ) in my Visual Studio 2015 project, but have no luck to have it successfully compiled due to the error as follows:


c:\users\sabro_000\downloads\gli-0.8.1.1\gli./core/load.inl(32): error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.


The error above is not at all new to me, since I have been seeing this error message many times always I tried to use deprecated
fopen
in VS2015. What I have been doing whenever I see this message is not going into
_CRT_SECURE_NO_WARNINGS
, but rather just use
fopen_s()
instead, as the message suggests because that's easier to solve it.

But now I get this error in OpenGL GLI, and would like to know how is anyone using OpenGL GLI on VS2015, getting rid of this error.

Answer

First off, it's a warning, not an error (at least on default settings). This means you can build and run your code just fine even with this warning.

Second, the simple solution is to do as the warning says and #define _CRT_SECURE_NO_WARNINGS. Note that the "more secure" functions ending in _s were never really adopted by C standard library vendors other than Microsoft, and there is a proposal to remove them from the standard again. You're probably better off not using them.