Search code examples
c++openglglm-math

No support for VS2015 in OpenGL GLI?


I am trying to use 'OpenGL Image' library 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.


Solution

  • 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 (or just add the macro to the compilation command line via project properties). 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.