Recently, when porting some STL code to VS2008 I wanted to disable warnings generated by std::copy
by defining the new _SCL_SECURE_NO_WARNINGS
flag. You can do this in two ways:
By defining it macro style before you include the relevant STL headers, or, for total coverage, in stdafx.h:
#define _SCL_SECURE_NO_WARNINGS
Both of these methods work fine but I wondered if there was any argument for favouring one over the other?
The /D option is generally used when you want to define it differently on different builds (so it can be changed in the makefile)
If you will "always" want it set the same way, use #define.
By putting them in your project file you maintain a close association between the platform specific warnings and the platform, which seems correct to me.
If they're in the code, they're always in the code whether or not it's appropriate for the platform. You don't need it for GCC or possibly future versions of Visual C++. On the other hand, by having it in the code, it's more obvious that it's there at all. If you move (copy) the code, it'll be easier to remember to move that define with it.
Pros and Cons each way. YMMV.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With