Windows compiler gives warning (#1786) for 'getenv' and 'fopen'

Windows compiler gives warning (#1786) for 'getenv' and 'fopen'

This C++ code is being ported from Linux. Is it safe to use these functions under Windows, or do I need to replace them with Windows specific equivalents?

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You may use these by including suitable header files.

fopen() include stdio.h
getenv() include stdio.h and stdlib.h

[shell]t.c(15): warning #1786: function "getenv" (declared at line 447 of "c:Program FilesMicrosoft Visual Studio 9.0VCINCL
UDEstdlib.h") was declared "deprecated ("This function or variable may be unsafe. Consider using _dupenv_s instead. To
disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.") "
     libvar = getenv( "LIB" );
              ^[/shell]

So it's above warning then. It would be better to use the new API.

Jennifer

Leave a Comment

Please sign in to add a comment. Not a member? Join today