Prev: error LNK2001: unresolved external symbol __forceAtlDllManifest
Next: CoCreateInstance() crashes
From: Dave Burns on 12 Jul 2006 11:24 Hi, I want to use the rand_s function in my application. I have included the following at the top of my module that uses the function: #define _CRT_RAND_S #include <cstdlib> I invoke the function as follows: unsigned number; errno_t err = rand_s(&number); The compiler generates the error "C3861: 'rand_s': identifier not found". I am using VS-2005. I looked in cstdlib and stdlib.h. I can see the declaration in stdlib.h as follows: #if defined(_CRT_RAND_S) _CRTIMP errno_t __cdecl rand_s ( __out unsigned int *_RandomValue); #endif There are a lot of "#if" statements in this header and I'm wondering if one of them is negating the declaration. Thanks for any advice, Dave
From: Dave Burns on 12 Jul 2006 11:35 I also tried adding the declaration to my module. It compiles now, but the linker fails with the following: error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl rand_s(unsigned int *)" (__imp_?rand_s@@YAHPAI@Z) referenced in function ... Dave
From: Igor Tandetnik on 12 Jul 2006 12:28 Dave Burns <dburns0000(a)aol.com> wrote: > Hi, I want to use the rand_s function in my application. > > I have included the following at the top of my module that uses the > function: > > #define _CRT_RAND_S > #include <cstdlib> > > I invoke the function as follows: > unsigned number; > errno_t err = rand_s(&number); Try std::rand_s. Note that you are including <cstdlib> rather than <stdlib.h> - presumably so that CRT functions be in std namespace. -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
|
Pages: 1 Prev: error LNK2001: unresolved external symbol __forceAtlDllManifest Next: CoCreateInstance() crashes |