C++ ISO Compliance
-
Having moved back to Visual Studio 2005, it is now bombarding me with warnings about ISO C++ deprecation of certain functions (such as strdup and stricmp). Most of these warnings disappear when I tell it to mind it's own business with _CRT_SECURE_NO_DEPRECATE. However, is it advisable to actually do what Microsoft say and switch everything over to the new versions of the functions?
-
Having moved back to Visual Studio 2005, it is now bombarding me with warnings about ISO C++ deprecation of certain functions (such as strdup and stricmp). Most of these warnings disappear when I tell it to mind it's own business with _CRT_SECURE_NO_DEPRECATE. However, is it advisable to actually do what Microsoft say and switch everything over to the new versions of the functions?
Yes the annoying security warnings ;-) There are many reasons to not use the new functions, even if MS recommends: - your code gets much more complicated - no cross-compiling with other compilers/operating systems possible - every open-source lib you use will bring again these warnings It is also widely not understood that the wrong functions were blamed by MS. Most of them are not unsafe and never were. But they depend on correct usage, so you as the programmer are in charge to not give them garbage. So, my advice is to use the old functions, and check (if you must use plain C) every buffer for long enough size, esp. if you get data from user input. Hans
-
Yes the annoying security warnings ;-) There are many reasons to not use the new functions, even if MS recommends: - your code gets much more complicated - no cross-compiling with other compilers/operating systems possible - every open-source lib you use will bring again these warnings It is also widely not understood that the wrong functions were blamed by MS. Most of them are not unsafe and never were. But they depend on correct usage, so you as the programmer are in charge to not give them garbage. So, my advice is to use the old functions, and check (if you must use plain C) every buffer for long enough size, esp. if you get data from user input. Hans
Thankyou, Hans. I was thinking something along the same lines, although I never thought of the cross-compatibility issue. Best to check. HWM