开发者

rand_s for MinGW

I have found the rand_s function, part of the CRT, to be extremely useful while developing my application. However, it is my understanding that it is not prototyped in recent MinGW header files.

Therefore I am asking for a comprehensive means of either providing or prototyping such a function. I have considered using an #ifdef MINGW style hook, however, this may fail should future revisions start prototyping the function.

Therefore, what is the best way of making the function available to my program su开发者_如何学Cch that it can be compiled with MinGW?


One hackish way to work around this is:

#define rand_s silly_function_name
#include <mingw.h>
#undef rand_s

extern errno_t rand_s (unsigned int *randomValue);

That way, if mingw starts providing a prototype for it, it will not interfere (unless they provide it as a macro, which is unlikely).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜