Parameter Validation
https://msdn.microsoft.com/en-us/library/ksazx244.aspx
Most of the security-enhanced CRT(C运行时) functions and many of the preexisting(先前存在的) functions validate their parameters. This could include checking pointers for NULL, checking that integers fall into a valid range, or checking that enumeration values are valid. When an invalid parameter is found, the invalid parameter handler is executed.
note:注意这时提到一些验证参数的例子,翻译如下:
一、指针是否为空。
二、整型是否会落入一个有效的范围。
三、检查枚举类型是否有效。
而且如果一个无效的参数被发现,会执行相应的无效参数处理机制。是每一种类型的参数异常对应一种处理机制吗?
Invalid Parameter Handler Routine
--------------------------------------------------------------------------------
The behavior of the C Runtime when an invalid parameter is found is to call the currently assigned invalid parameter handler. The default(note:这里应该指的是运行时,而不是调试时) invalid parameter invokes Watson crash reporting, which causes the application to crash and asks the user if they want to load the crash dump to Microsoft for analysis. In Debug mode, an invalid parameter also results in a failed assertion.
This behavior can be changed by using the function _set_invalid_parameter_handler to set the invalid parameter handler to your own function.(note:你可以通过set_invalid_parameter_handler 函数来设定无效参数 的处理机制到你自己定义的函数) If the function you specify does not terminate the application, control is returned to the function that received the invalid parameters, and these functions will normally cease execution, return an error code(note:这个收到无效参数的函数会正常地结束执行,并返回一个错误码。注意反省一下,自己在处理相应的问题时,对于非法输入是都能返回相应的错误码。), and set errno to an error code. In many cases, the errno value and the return value are both EINVAL, indicating an invalid parameter. In some cases, a more specific error code is returned, such as EBADF for a bad file pointer passed in as a parameter. For more information on errno, see errno, _doserrno, _sys_errlist, and _sys_nerr.
-------------------
ASK:为什么返回值中有了错误码,还要另外再用一个errno