[antlr-interest] C++ compile issue with ANTLR 3.1.0b1 C runtimefiles

Chris Snyder snyder at t-vec.com
Thu Mar 13 11:55:06 PDT 2008


Hi Jim,

 

It is because we define WIN32_LEAN_AND_MEAN to exclude most of the unused
stuff in our application. That macro prevents winsock.h from getting
included by windows.h.

 

I can include the header. It does not appear to hurt anything.

 

Thanks,

Chris

 

  _____  

From: Jim Idle [mailto:jimi at temporal-wave.com] 
Sent: Thursday, March 13, 2008 2:22 PM
To: snyder at t-vec.com
Subject: RE: [antlr-interest] C++ compile issue with ANTLR 3.1.0b1 C
runtimefiles

 

Yeah - but what I want to know is why does everyone else's environment
autoinclude it like mine does, but yours does not. I can include winsock_2.h
but I am not convinced that you are supposed to. Maybe you are though, it
probably does not harm.

 

Unless I start making the release version of the library #define out the
socket related stuff for the debugger, then I would have to create a
separate library and dynamically load it on each platform when the debugger
is invoked. I did think about doing that, but then I have to write platform
agnostic dll_open code, which isn't a huge problem but I didn't really have
time. Linking with the dll version of winsock shouldn't be a big deal as it
won't use up much space if you don't use the debugger (which I have not got
working yet anyway ;-). Maybe I will come back to that later.

 

Jim

 

From: Chris Snyder [mailto:snyder at t-vec.com] 
Sent: Thursday, March 13, 2008 11:05 AM
To: Jim Idle
Subject: RE: [antlr-interest] C++ compile issue with ANTLR 3.1.0b1 C
runtimefiles

 

VS2005 SP1 is installed.

 

If I include <winsock.h> before I include my lexer.h file it compiles fine.

 

It would be nice to remove this requirement if you are not going to be using
the debug facility. The application I'm working on does not use sockets.

 

It looks like you can check to see if _WINSOCKAPI_ is defined and if it is
not then include winsock.h.

 

Thanks,

Chris

 

  _____  

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jim Idle
Sent: Thursday, March 13, 2008 1:45 PM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] C++ compile issue with ANTLR 3.1.0b1 C
runtimefiles

 

Hmm, how are you compiling it? I have no come across this and I just 10
seconds ago compiled generated code as C++ to fix a casting issue that
someone else reported. If you have all the correct headers and include paths
set up, then you should find in winsock.h:

 

typedef UINT_PTR        SOCKET;

 

Right clicking on the SOCKET declaration in antlr3debugeventlistener.h
should take you straight to it (once you have compiled and have the browse
info etc). So, if it doesn't then there is something amiss with your build
environment, or you have perhaps #defined something before including the
antlr3.h header, or in the project etc, which is causing the winsock
includes to not include themselves.

 

Including antlr3.h should include everything for you regardless of the
operating system/compiler, so it would be nice to get to the bottom of this
so we can solve it for others in advance ;-) This error usually means that
you are including the wrong headers. Did you load the .Net SDK or otherwise
change the default header locations for VS 2005? This kind of error comes up
when you install the wrong platform SDKs or out of date ones, but after
VS2005 these types of problems seemed to go away because the header include
order was fixed. 

 

Finally, you have installed VS2005 SP 1 right?

 

Jim

 

 

 

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Chris Snyder
Sent: Thursday, March 13, 2008 10:13 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] C++ compile issue with ANTLR 3.1.0b1 C runtime
files

 

I'm trying to compile my C output in CPP and I get this error

 

libantlr3c-3.1.0b1\include\antlr3debugeventlistener.h(42) : error C2146:
syntax error : missing ';' before identifier 'socket'

 

which corresponds to this:

 

antlr3debugeventlistener.h

/// The socket structure we receive after a successful accept on the
serverSocket

///

SOCKET                        socket;

 

I looked for the SOCKET definition and didn't find one being used in my
configuration. I did find a UNIX definition in antlr3defs.h:

 

// SOCKET not defined on Unix

// 

typedef     int                     SOCKET;

 

but it is not even reached because preprocessor ANTLR3_WINDOWS is defined 

 

Should I be including a windows socket header?

 

I'm in windows XP using VS2005 and VC++ 2005.

 

Thanks,

Chris

 

 

T-VEC Technologies, Inc.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080313/d753c756/attachment-0001.html 


More information about the antlr-interest mailing list