Wednesday 15 June 2011

c++ - How to resolve this compilation error -


I'm trying to compile some OpenGL code because I get this error

1 & gt; C: \ users \ student \ documents \ visual studio 2012 \ projects \ openglproject1 \ openglproject1 \ initshader.h (10): error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead to disable the exclusion, see _CRT_SECURE_NO_WARNINGS Use Online Help for information. Include Program

  # "Angel.h" Namespace Angel {// Create a redundant string by reading a given file static characters * readShaderSource (const char * shaderFile ) {FILE * fp = fopen (shaderfile, "r"); If (FP == faucet) {return tap; } Fseek (FP, 0L, SEEK_END); Long Size = Feet (FP); Fseek (FP, 0L, SEEK_SET); Four * buf = new four [size + 1]; Fred (buff, 1, size, FP); Buf [size] = '\ 0'; Fclose (fp); Return buff; } // Create a GLSL program object. Gluint InitShader from top and slice shader files (const char * vShaderFile, const char * fShaderFile) {struct shader {const char * filename; Gelennum type; GLchar * source; } Shaders [2] = {{vShaderFile, GL_VERTEX_SHADER, NULL}, {fShaderFile, GL_FRAGMENT_SHADER, NULL}}; Glume program = glucac program (); For (Int i = 0; I   

Can you tell me how do I modify the program?

You can define a header file that generates an error, before adding the header file Or "project-> property- & gt;" The project can be applied to the entire project by adding settings. Configuration Properties- & gt; C / C ++ - & gt; Preprocessor- & gt; Preprocessor Definitions

  #define _CRT_SECURE_NO_WARNINGS #include "initshader.h" // ... here your code   

if you are using pre-compiled headers And if the header that generates the errors is included in stdafx.h , then add it to the stdafx.h header or in your project settings as described above.

No comments:

Post a Comment