From: Huevos on 7 Dec 2006 20:27 I've had newsgroup problems today, so sorry if this comes out as a duplicate... In Visual Studio 2005, in a Visual C++ solution, I tried to do this: #define _CRT_RAND_S #include <stdlib.h> // Microsoft's default code for a MFC Dialog Application UINT number; errno_t err; err = rand_s( &number ); However, I could tell right away something wasn't right, as when I types "rand_s(", the argument list didn't pop up... It seems it may not be finding stdlib.h or something. I am not super familiar with Visual Studio 2005, so don't know where to begin to try to figure out why. Can anyone help? Thanks in advance.
From: Doug Harrison [MVP] on 7 Dec 2006 22:02 On Fri, 08 Dec 2006 01:27:49 GMT, "Huevos" <humanjhawkins(a)earthlink.net> wrote: >I've had newsgroup problems today, so sorry if this comes out as a >duplicate... > >In Visual Studio 2005, in a Visual C++ solution, I tried to do this: > > #define _CRT_RAND_S > #include <stdlib.h> > > // Microsoft's default code for a MFC Dialog Application > UINT number; > errno_t err; > err = rand_s( &number ); > >However, I could tell right away something wasn't right, as when I types >"rand_s(", the argument list didn't pop up... It seems it may not be finding >stdlib.h or something. > >I am not super familiar with Visual Studio 2005, so don't know where to >begin to try to figure out why. Can anyone help? It's likely that your stdafx.h is (indirectly) #including <stdlib.h>, in which case, your #define will have no effect. Try placing your #define at the top of stdafx.h or define it in your preprocessor options. -- Doug Harrison Visual C++ MVP
From: Joseph M. Newcomer on 7 Dec 2006 22:41 On Fri, 08 Dec 2006 01:27:49 GMT, "Huevos" <humanjhawkins(a)earthlink.net> wrote: >I've had newsgroup problems today, so sorry if this comes out as a >duplicate... > >In Visual Studio 2005, in a Visual C++ solution, I tried to do this: > > #define _CRT_RAND_S > #include <stdlib.h> > > // Microsoft's default code for a MFC Dialog Application > UINT number; > errno_t err; > err = rand_s( &number ); > >However, I could tell right away something wasn't right, as when I types >"rand_s(", the argument list didn't pop up... It seems it may not be finding >stdlib.h or something. **** So Intellisense didn't work. So what? You have the spec correct, so what does the prompting matter? Did it compile? If it compiled, don't worry about irrelevancies. **** > >I am not super familiar with Visual Studio 2005, so don't know where to >begin to try to figure out why. Can anyone help? > >Thanks in advance. > Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Huevos on 8 Dec 2006 02:48 "Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message news:ulnhn215o2gookd40f4ou6p9d2hm4ohcnu(a)4ax.com... > On Fri, 08 Dec 2006 01:27:49 GMT, "Huevos" <humanjhawkins(a)earthlink.net> > wrote: > >>However, I could tell right away something wasn't right, as when I types >>"rand_s(", the argument list didn't pop up... It seems it may not be >>finding >>stdlib.h or something. > **** > So Intellisense didn't work. So what? You have the spec correct, so what > does the > prompting matter? Did it compile? If it compiled, don't worry about > irrelevancies. > **** I apologize for not writing more clearly. I will really try to work on that as I appreciate the time you spend and don't want to waste any of it. It did also fail to compile. Doug Harrison's suggestion was a success, though I am not sure I understand why.
From: Doug Harrison [MVP] on 8 Dec 2006 12:42 On Fri, 08 Dec 2006 07:48:28 GMT, "Huevos" <humanjhawkins(a)earthlink.net> wrote: >It did also fail to compile. Doug Harrison's suggestion was a success, >though I am not sure I understand why. You were essentially doing this: #include "stdafx.h" #define _CRT_RAND_S #include <stdlib.h> Almost all header files contain guards or #pragmas that prevent their multiple inclusion, and <stdlib.h> is no exception. Therefore, #including <stdlib.h> after "stdafx.h" has no effect, because <stdlib.h> has already been #included. Inside <stdlib.h>, you'll find this: #if defined(_CRT_RAND_S) _CRTIMP errno_t __cdecl rand_s ( __out unsigned int *_RandomValue); #endif When "stdafx.h" #included <stdlib.h>, _CRT_RAND_S was not #defined, so rand_s was not declared. In order for your macro to cause the declaration of rand_s, it has to be defined before <stdlib.h> is #included, hence my advice to "try placing your #define at the top of stdafx.h or define it in your preprocessor options." -- Doug Harrison Visual C++ MVP
|
Pages: 1 Prev: A little help with a LNK2019 error? Next: Help with CHTMLView and Session |