Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
STL components in VC++ 6.0

 
Post new topic   Reply to topic Printable version
 View previous topic  Bot Error? Post :: Post Jp Negtive fixier  View next topic  
Author Message
tansey
Novice


Joined: Nov 03 2004
Posts: 53
Offline

PostPosted: Tue Dec 21, 2004 5:26 am    Post subject: STL components in VC++ 6.0 Reply to topic Reply with quote

I'm trying to use a couple of simple container classes in my bot ( a map and a set) and VC++ 6.0 doesn't want to let the thing compile.

I've got a separate header and cpp file for my actual core. So I'm trying to make my bot have 2 fields, one map and one set, and I'm declaring them as such:

Code: Show/Hide
   set<int>               set1;      
   map <Player*, int>         map1;               



I'm constantly getting errors like:
Quote:
c:\program files\continuum\mervbot\src\r2g2\dt.h(104) : error C2143: syntax error : missing ';' before '<'
c:\program files\continuum\mervbot\src\r2g2\dt.h(104) : error C2501: 'set' : missing storage-class or type specifiers
c:\program files\continuum\mervbot\src\r2g2\dt.h(104) : error C2059: syntax error : '<'
c:\program files\continuum\mervbot\src\r2g2\dt.h(104) : error C2238: unexpected token(s) preceding ';'


Not sure what's going on here. Any help would be appreciated.
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Tue Dec 21, 2004 1:07 pm    Post subject: Reply to topic Reply with quote

Make sure you have the line "using namespace std;" at the top of every file that uses STL classes.

Also make sure you don't ever use STL classes because they're the worst thing to debug in ages.
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
tansey
Novice


Joined: Nov 03 2004
Posts: 53
Offline

PostPosted: Tue Dec 21, 2004 1:25 pm    Post subject: Reply to topic Reply with quote

Yep, tried that...
When i did using namespace std but it said:
Quote:
c:\program files\continuum\mervbot\src\hostbot\hostbot.h(15) : error C2871: 'std' : does not exist or is not a namespace
Back to top
View users profile Send private message Add User to Ignore List
Underlord
Novice


Gender:Gender:Male
Joined: Feb 17 2004
Posts: 55
Offline

PostPosted: Tue Dec 21, 2004 2:21 pm    Post subject: Reply to topic Reply with quote

Quote:
c:\program files\continuum\mervbot\src\hostbot\hostbot.h(15) : error C2871: 'std' : does not exist or is not a namespace


Most likely cause for that is .... you put "using namespace std;" under a traditional header file ".h".

Code: Show/Hide

#include <fstream>
using namespace std;

right

#include <fstream.h>
using namespace std;

wrong


If you setup a namespace where you declare map/set, then u can access them elsewhere after includes with
" what_you_called_your_namespace::set <int> setl; "
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
tansey
Novice


Joined: Nov 03 2004
Posts: 53
Offline

PostPosted: Tue Dec 21, 2004 3:41 pm    Post subject: Reply to topic Reply with quote

Thanks so far! But now it's giving me more errors:

Quote:
c:\program files\continuum\mervbot\src\hostbot\hostbot.h(144) : warning C4786: 'std::pair<std::_Tree<int,int,std::set<int,std::less<int>,std::allocator<int> >::_Kfn,std::less<int>,std::allocator<int> >::const_iterator,std::_Tree<int,int,std::set<int
,std::less<int>,std::allocator<int> >::_Kfn,std::less<int>,std::allocator<int> >::const_iterator>' : identifier was truncated to '255' characters in the debug information
c:\program files\continuum\mervbot\src\hostbot\hostbot.h(144) : warning C4786: 'std::reverse_bidirectional_iterator<std::_Tree<Player *,std::pair<Player * const,int>,std::map<Player *,int,std::less<Player *>,std::allocator<int> >::_Kfn,std::less<Pla
yer *>,std::allocator<int> >::iterator,std::pair<Player * const,int>,std::pair<Player * const,int> &,std::pair<Player * const,int> *,int>' : identifier was truncated to '255' characters in the debug information
c:\program files\continuum\mervbot\src\hostbot\hostbot.h(144) : warning C4786: 'std::reverse_bidirectional_iterator<std::_Tree<Player *,std::pair<Player * const,int>,std::map<Player *,int,std::less<Player *>,std::allocator<int> >::_Kfn,std::less<Pla
yer *>,std::allocator<int> >::const_iterator,std::pair<Player * const,int>,std::pair<Player * const,int> const &,std::pair<Player * const,int> const *,int>' : identifier was truncated to '255' characters in the debug information
c:\program files\continuum\mervbot\src\hostbot\hostbot.h(144) : warning C4786: 'std::pair<std::_Tree<Player *,std::pair<Player * const,int>,std::map<Player *,int,std::less<Player *>,std::allocator<int> >::_Kfn,std::less<Player *>,std::allocator<int>
>::iterator,std::_Tree<Player *,std::pair<Player * const,int>,std::map<Player *,int,std::less<Player *>,std::allocator<int> >::_Kfn,std::less<Player *>,std::allocator<int> >::iterator>' : identifier was truncated to '255' characters in the debug in
formation
c:\program files\continuum\mervbot\src\hostbot\hostbot.h(144) : warning C4786: 'std::pair<std::_Tree<Player *,std::pair<Player * const,int>,std::map<Player *,int,std::less<Player *>,std::allocator<int> >::_Kfn,std::less<Player *>,std::allocator<int>
>::const_iterator,std::_Tree<Player *,std::pair<Player * const,int>,std::map<Player *,int,std::less<Player *>,std::allocator<int> >::_Kfn,std::less<Player *>,std::allocator<int> >::const_iterator>' : identifier was truncated to '255' characters in
the debug information


Also, it's having trouble with the String class being recognized:

Quote:
c:\program files\continuum\mervbot\src\hostbot\spawn.h(242) : error C2664: 'void __thiscall botInfo::sendPublic(char *)' : cannot convert parameter 1 from 'class String' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Back to top
View users profile Send private message Add User to Ignore List
tansey
Novice


Joined: Nov 03 2004
Posts: 53
Offline

PostPosted: Tue Dec 21, 2004 5:43 pm    Post subject: Reply to topic Reply with quote

Okay, I figured out the issues with the map, but my String issues are still there. For some reason, it's not acknowledging the operator overloaders or the copy constructors or anything like that.

Is it maybe because of my namespace std; declaration, since String is a class not in that namespace?
Back to top
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Tue Dec 21, 2004 5:54 pm    Post subject: Reply to topic Reply with quote

Knitting is a fun hobby I hear.
_________________
4,691 irradiated haggis!
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Tue Dec 21, 2004 6:01 pm    Post subject: Reply to topic Reply with quote

Make sure "#define STRING_CAST_CHAR" is at the top of spawn.h.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
tansey
Novice


Joined: Nov 03 2004
Posts: 53
Offline

PostPosted: Tue Dec 21, 2004 6:44 pm    Post subject: Reply to topic Reply with quote

Yep, it is.

The top of my bot's .h file (separate file, not spawn.h):

Code: Show/Hide

#ifndef HOSTBOT_H
#define HOSTBOT_H

#include "..\dllcore.h"
#include <map>
#include <set>
#include <iostream>
using namespace std;

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
Back to top
View users profile Send private message Add User to Ignore List
D1st0rt
Miss Directed Wannabe


Age:37
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Tue Dec 21, 2004 7:41 pm    Post subject: Reply to topic Reply with quote

ouch Ekted, lol

do you not like the STL?
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Tue Dec 21, 2004 8:08 pm    Post subject: Reply to topic Reply with quote

Ekted is old skewl... icon_wink.gif He's too good for STL icon_smile.gif... lol.
_________________
Performance is often the art of cheating carefully. - James Gosling
Back to top
View users profile Send private message Add User to Ignore List
D1st0rt
Miss Directed Wannabe


Age:37
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Tue Dec 21, 2004 8:18 pm    Post subject: Reply to topic Reply with quote

maybe some day I will level up into a Mr Ekted
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
tansey
Novice


Joined: Nov 03 2004
Posts: 53
Offline

PostPosted: Tue Dec 21, 2004 8:28 pm    Post subject: Reply to topic Reply with quote

um....is there any other library you guys would reccommend to use that has both a map and a set class? I know stl has a lot of memory leaks, but it's all I know! icon_sad.gif
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Tue Dec 21, 2004 11:02 pm    Post subject: Reply to topic Reply with quote

I don't see it at the top of that file. And it should be in the spawn.h.

As far as STL goes, you'll learn a lot about the language if you do it yourself. That's what I did, and man, do I feel in control of my program. icon_razz.gif

And, of course, you can always re-use a template class once you've made one.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Wed Dec 22, 2004 1:15 am    Post subject: Reply to topic Reply with quote

D1st0rt wrote:
ouch Ekted, lol

do you not like the STL?


I dislike all wrappers for common stuff. They always add inefficiency, and even if they are bug-free, they are often mis-used by interface or mis-used by the incorrect choice of aggregate type. IMO, you learn how things work and how to implement them, or you do something else.

When I see code like this, it makes me want to puke:

Code: Show/Hide
String Function (String a, String b)
{
return a + " - " + b;
}


Do you have any idea how bad this code is? I believe this would perform four memory allocations, instead of an acceptible zero.
Back to top
View users profile Send private message Add User to Ignore List
tansey
Novice


Joined: Nov 03 2004
Posts: 53
Offline

PostPosted: Wed Dec 22, 2004 5:17 am    Post subject: Reply to topic Reply with quote

I've written all these classes on my own before too, for my CS classes...but I would tend to think that a guy who's only got 7 months c++ experience wouldn't make as efficient a map/set class as the stl writers (HP?)
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Wed Dec 22, 2004 10:51 am    Post subject: Reply to topic Reply with quote

Oh, they might not be efficient, but you can always improve them in the future. The ease of debugging makes up for any slight efficiency loss.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Wed Dec 22, 2004 11:33 am    Post subject: Reply to topic Reply with quote

No matter how efficient the String class is, you can write the code above that runs 10-20x faster, and it's MUCH easier to debug.
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Wed Dec 22, 2004 11:38 am    Post subject: Reply to topic Reply with quote

You can't perform less than two allocations for that functions task.

I agree that having that code inline would be much easier to debug, though.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Wed Dec 22, 2004 12:49 pm    Post subject: Reply to topic Reply with quote

You could only perform one allocation if the class was designed properly.

And my talking about efficiency was mainly targeted towards var-length arrays, trees, etc.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Wed Dec 22, 2004 6:01 pm    Post subject: Reply to topic Reply with quote

STL doesn't have memory leaks, where did you hear that?

the String class is not STL's class... it's written by catid
Back to top
View users profile Send private message Add User to Ignore List AIM Address
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Wed Dec 22, 2004 6:45 pm    Post subject: Reply to topic Reply with quote

I wrote a string class once.
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Wed Dec 22, 2004 11:42 pm    Post subject: Reply to topic Reply with quote

OMFG I DID TOO OMG OMG OMG WHAT'S YOUR #??
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
D1st0rt
Miss Directed Wannabe


Age:37
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Thu Dec 23, 2004 11:41 am    Post subject: Reply to topic Reply with quote

I wrote a string class never.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 72 page(s) served in previous 5 minutes.

phpBB Created this page in 0.554287 seconds : 49 queries executed (91.8%): GZIP compression disabled