문제

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 such 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).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top