Home > Net >  How do I define __cpp_exceptions for gsl:narrow to compile?
How do I define __cpp_exceptions for gsl:narrow to compile?

Time:10-04

I am getting confused again :(

I have looked at this discussion:

enter image description here

(Note: This works in Visual Studio 2019. I don't have V/S 2022 installed on my PC, so I can't check it in that version – but I would imagine the process is very similar.)

The following short console-mode program demonstrates the difference caused by changing that setting:

#include <iostream>
int main()
{
    #ifdef __cpp_exceptions
    std::cout << "yes";    // With "Yes (/EHsc)"
    #else
    std::cout << "no";     // With "No"
    #endif
    std::cout << std::endl;
    return 0;
}
  • Related