Help with VC++ 6.0 compiler warning

Programming Topics (Computer Chess) and technical aspects as test techniques, book building, program tuning etc

Moderator: Andres Valverde

Help with VC++ 6.0 compiler warning

Postby Ron Murawski » 17 Jan 2006, 03:32

I have drastically reduced level 4 warnings (using the MS VC++ 6.0 compiler). I started with more than 200 warnings. I want to eliminate all of them! My program is written in C. I'm getting a warning that confounds me. Here it is:

Compiling...
Horizon.c
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\rpcasync.h(45) : warning C4115: '_RPC_ASYNC_STATE' : named type definition in parentheses
Linking...

Horizon.exe - 0 error(s), 1 warning(s)


I've found this reference at microsoft.com:
http://msdn2.microsoft.com/en-us/library/hhzc0806.aspx
which states:
Compiler Warning (levels 1 and 4) C4115
"The given symbol is used to define a structure, union, or enumerated type inside a parenthetical expression. The scope of the definition may be unexpected. In a C function call, the definition has global scope. In a C++ call, the definition has the same scope as the function being called. This warning can also be caused by declarators within parentheses (such as prototypes) that are not parenthetical expressions."

None of my code has an obvious need for rpcasync.h, so I would assume VC++ is automatically including it for some reason.

The offending line from rpcasynch.h:
Code: Select all
RPCNOTIFICATION_ROUTINE (
   struct _RPC_ASYNC_STATE *pAsync, // <-- line 45
   void *Context,                             
   RPC_ASYNC_EVENT Event);


My questions:
* Where does this warning come from?
* What causes it?
* How do I make it go away?

Thanks,
Ron
User avatar
Ron Murawski
 
Posts: 352
Joined: 26 Sep 2004, 21:50
Location: Schenectady, NY, USA

Re: Help with VC++ 6.0 compiler warning

Postby Ron Murawski » 17 Jan 2006, 03:48

I have eliminated the error with:

Code: Select all
#pragma warning (disable: 4115)


but I would still like to understand the root cause.

Ron
User avatar
Ron Murawski
 
Posts: 352
Joined: 26 Sep 2004, 21:50
Location: Schenectady, NY, USA

Re: Help with VC++ 6.0 compiler warning

Postby Dann Corbit » 17 Jan 2006, 04:01

Ron Murawski wrote:{snip}
My questions:
* Where does this warning come from?

Ron Murawski wrote:A Microsoft Header file

Ron Murawski wrote: * What causes it?

Ron Murawski wrote:A parameter that is a struct without the struct definition in scope.

Ron Murawski wrote: * How do I make it go away?

Ron Murawski wrote:Put Windows.h in scope before any other header file.

Ron Murawski wrote:Thanks,
Ron


E.g.

/* this is a header file */
int foobar (struct barfoodongle *flippy_the_clown);
/* this is the end of a header file */

Now, if you include that header file without first including another header file that tells us what a struct barfoodongle is, we will get that error.
Dann Corbit
 

Re: Help with VC++ 6.0 compiler warning

Postby Ron Murawski » 17 Jan 2006, 04:45

Dann Corbit wrote:
Ron Murawski wrote:{snip}
Ron Murawski wrote: * How do I make it go away?

Dann Corbit wrote:Put Windows.h in scope before any other header file.




That doesn't seem to work :(

Ron
User avatar
Ron Murawski
 
Posts: 352
Joined: 26 Sep 2004, 21:50
Location: Schenectady, NY, USA

Re: Help with VC++ 6.0 compiler warning

Postby Jim Ablett » 17 Jan 2006, 06:49

Hi Ron,

<Windows.h> includes <Rpc.h> which includes <rpcasync.h>

Examining <Rpc.h> reveals you can switch off <rpcasync.h>
by defining ( RPC_NO_WINDOWS_H )

regards,

Jim.
___________________________
http://jimablett.net63.net/
Jim Ablett
 
Posts: 721
Joined: 27 Sep 2004, 10:39
Location: Essex, England

Re: Help with VC++ 6.0 compiler warning

Postby Ron Murawski » 17 Jan 2006, 19:38

Jim Ablett wrote:Hi Ron,

<Windows.h> includes <Rpc.h> which includes <rpcasync.h>

Examining <Rpc.h> reveals you can switch off <rpcasync.h>
by defining ( RPC_NO_WINDOWS_H )

regards,

Jim.


Hi Jim,

That works. Thanks!

I also found
#define WIN32_LEAN_AND_MEAN
will also stop the warning and prevent the compiler from including non-essential stuff such as the rpc call header. Seems to speed up the compile, too.

Ron
User avatar
Ron Murawski
 
Posts: 352
Joined: 26 Sep 2004, 21:50
Location: Schenectady, NY, USA


Return to Programming and Technical Discussions

Who is online

Users browsing this forum: No registered users and 9 guests