Sierra Chart | Custom Study

Sierra Chart | Handling “function or variable may be unsafe” unsafe when compiling Sierra Chart Custom Study

You are compiling your study and getting these warnings.

We want the output of compiling to be clean. No errors and no warnings.
1>—— Build started: Project: demo, Configuration: Debug Win32 ——
1>  SCStudies.cpp
1>d:demosierrachartacs_sourcesierrachart.h(385): warning C4996: ‘strcpy’: This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:program files (x86)microsoft visual studio 10.0vcincludestring.h(105) : see declaration of ‘strcpy’
1>d:demosierrachartacs_sourcesierrachart.h(412): warning C4996: ‘strcpy’: This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:program files (x86)microsoft visual studio 10.0vcincludestring.h(105) : see declaration of ‘strcpy’
1>d:demosierrachartacs_sourcesierrachart.h(536): warning C4996: ‘_vsnprintf’: This function or variable may be unsafe. Consider using _vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:program files (x86)microsoft visual studio 10.0vcincludestdio.h(363) : see declaration of ‘_vsnprintf’
1>d:demosierrachartacs_sourcesierrachart.h(707): warning C4996: ‘strncpy’: This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:program files (x86)microsoft visual studio 10.0vcincludestring.h(188) : see declaration of ‘strncpy’
1>d:demosierrachartacs_sourcesierrachart.h(708): warning C4996: ‘strncpy’: This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:program files (x86)microsoft visual studio 10.0vcincludestring.h(188) : see declaration of ‘strncpy’
1>d:demosierrachartacs_sourcesierrachart.h(748): warning C4996: ‘strncpy’: This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:program files (x86)microsoft visual studio 10.0vcincludestring.h(188) : see declaration of ‘strncpy’
1>d:demovcprojectscstudiesscstudies.cpp(79): warning C4244: ‘=’ : conversion from ‘float’ to ‘int’, possible loss of data
1>d:demovcprojectscstudiesscstudies.cpp(81): warning C4244: ‘=’ : conversion from ‘int’ to ‘float’, possible loss of data
1>     Creating library d:demosierrachartdatademo.lib and object d:demosierrachartdatademo.exp
1>  SCStudies.vcxproj -> d:demosierrachartdatademo.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

You probably have windows.h included at the top of your file. It is in there by default with the Sierra Chart default project template. If you don’t need it, just remove the include and the warnings should go away. If you are not sure if you need it, just remove it, compile and see if it succeeds – if it builds ok you don’t need the windows.hAanother option is to define _CRT_SECURE_NO_WARNINGS prior to including CRT headers and this will make the warning go away.Not the cleanest way to do this but you can also do the following and it will remove the warnings:#define _CRT_SECURE_NO_WARNINGS 1

#include <Windows.h>
#include “d:demoSierrachartACS_Sourcesierrachart.h”

That should provide a clean build.

A cleaner way to resolve this is to add the _CRT_SECURE_NO_WARNINGS define to the project properties in the precompile section. See image below.

Sierra Chart | Custom Study

Sierra Chart | Custom Study