2

I'm starting with Quantlib in C++ and am trying to run an example code. I've been following the tutorial in

https://www.youtube.com/watch?v=Wn_D19c2ABU&t=569s

I'm confused when, at 5:36, he writes the following directives (?) to the preprocessor:

_SCL_SECURE_NO_DEPRECATE
_CRT_SECURE_NO_DEPRECATE

So my questions would be:

1) Why is this necessary?
2) Is this a Quantlib thing or needed for Boost library?
3) Is this always necessary when including external libraries?

Let's say I want to use a different pricing library, should I need to do the same?

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Nick Ben
  • 53
  • 2
  • 6

2 Answers2

2

Boost said this in an old version of its docs:

Microsoft Visual C++ 6.0 (sp5, with and without STLport), 7.0, 7.1, 8.0. Note: Boost does not support the non-standard "Safe" C++ Library shipping with Visual C++ 8.0, which may result in many spurious warnings from Boost headers and other standards-conforming C++ code. To suppress these warnings, define the macro _SCL_SECURE_NO_DEPRECATE.

So basically, defining those two things avoids compiler warnings. You can try building your project without them first, and only add them if needed.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
2

It's a Microsoft thing. They argue that some versions of the standard library functions are more secure than others. Not everyone agree.

However, they also believe that the inexperienced users, perhaps in most need of the "secure" versions, might not know that so the warnings are enabled by default.

More experienced programmers, who can tell the difference, will also understand how to turn the warnings off:

Disabling Warnings generated via _CRT_SECURE_NO_DEPRECATE

Bo Persson
  • 90,663
  • 31
  • 146
  • 203