Game mud programming code error

Started by
5 comments, last by muphicks 19 years, 11 months ago
Lo all, Anyone here bought the mud game programming book by ron penton? I''ve worked through to the chapter on connection managers and protocols. This uses a lot of template code and for some reason I cannot get any of it to compile under vc++ 2003. Are there any known problems with the way vc++ 2003 handles template code? Or any program updates I''m not aware of. If nobodys got the book, or having a similar prob, I''ll dig out the error messages and post those to see if anyone has any ideas. I''m at work atm though so don''t have access to the code errors.
Advertisement
VC7.1 does a pretty good job with templates.
What errors do you get, precisely?

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
quote:Original post by Fruny
VC7.1 does a pretty good job with templates.
What errors do you get, precisely?

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan


m, 7.1 is one of the better compilers
reality is only an option
Hi,

Heres the first few errors I get, there are way too many more to list, but I imagine their all related to the earlier errors.

h:\Programming\MUD\Examples\Libraries\SocketLib\ConnectionManager.h(35): warning C4346: ''std::list<SocketLib::Connection<_Ty>>::iterator'' : dependent name is not a type

h:\Programming\MUD\Examples\Libraries\SocketLib\ConnectionManager.h(35): error C2146: syntax error : missing '';'' before identifier ''clistitr''

h:\Programming\MUD\Examples\Libraries\SocketLib\ConnectionManager.h(35): error C2501: ''SocketLib::ConnectionManager<protocol,defaulthandler>::clistitr'' : missing storage-class or type specifiers

h:\Programming\MUD\Examples\Libraries\SocketLib\ConnectionManager.h(108): error C2061: syntax error : identifier ''clistitr''


By the fourth error the clistitr is no longer been found, despite been typedef''d. I think this is because the earlier errors/warnings are indicating a problem withthose lines of code.

Heres the code for those surrounding lines (well a portion of it)


namespace SocketLib
{

// Forward Declarations
template<typename protocol> class Connection;



// ============================================================================
// Description: This connection manager class will manage connections,
// all identified with an ID.
// ============================================================================
template<typename protocol, typename defaulthandler> class ConnectionManager
{

typedef std::list< Connection<protocol> > clist;
typedef std::list< Connection<protocol> >::iterator clistitr;

public:
// ------------------------------------------------------------------------
// This creates a connection manager using a maximum datarate, buffer size,
// and a send timeout limit.
// ------------------------------------------------------------------------
ConnectionManager( int p_maxdatarate = 1024, // 1 kbyte/second
int p_sentimeout = 60, // 60 seconds
int p_maxbuffered = 8192 ); // 8 kbytes

......... rest of code

The lines reported in the warning/error in the above code are:

typedef std::list< Connection<protocol> > clist;
typedef std::list< Connection<protocol> >::iterator

I''ve done a bit of digging and read about maybe needing to add "typename" but doing so does not seem to resolve the issue.
forgot to login before posting the above reply.
Try
typedef typename std::list< Connection > clist;typedef typename std::list< Connection >::iterator clistitr; 


Older versions of Visual Studio were more lenient with that kind of things.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
/emote hands over a virtual larger for good advice

Well I was on the right line for typename then, just adding it in the wrong place I''m only just starting my journey into using templates.

Anyhow, that resolves the main errors. Still getting others, but their no biggy. Cheers the help everyone, especially for such quick replys

This topic is closed to new replies.

Advertisement