Reputation: 443
I have a code in C# that uses _set_invalid_parameter_handler function. It's Windows specific and i am trying to rewrite this code in standard C++ so it runs on Linux.
I am not sure how to translate this functionality. I was advised to use maybe http://en.cppreference.com/w/c/error/set_constraint_handler_s but i have followed this example and the types of constraint handlers aren't recognized in visual studio 2015 nor when i try to compile it on Linux. Will appreciate some help either using constraint handlers or finding some other way to replicate _set_invalid_parameter_handler functionality in standard C++.
Upvotes: 3
Views: 519
Reputation: 12527
It's not so easy set_constraint_handler is a C11-functionality, and set_invalid_parameter is Microsoft-specific (also in C++).
In standard C++ the solution is to use exceptions, and try/catch instead of setting a handler - but it requires that the low-level functions you call actually detect and signal errors with exceptions - so we would need a more complete example to see if this helps.
Upvotes: 0