.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Programming (http://forums.bots-united.com/forumdisplay.php?f=25)
-   -   c++ noob stuff (http://forums.bots-united.com/showthread.php?t=5870)

commonbullet 04-11-2006 20:14

c++ noob stuff
 
hi,
check this example:
PHP Code:

#include <map>
#include <string>
#include <stdio.h>

using namespace std;

int main() {
    
map <stringstringtest;
    
test["anykey"] = "anyvalue";
    
printf("anykey -> %s"test["anykey"].c_str());
    return 
0;


It complies ok in msvc++ 6.0 and it also seems to work. But I get so much warnings (about 107), I'm afraid police is coming to arrest me or something.
Any ideas?

thanks.

@$3.1415rin 04-11-2006 20:50

Re: c++ noob stuff
 
post removed, stupid idea, it was too late :D :)

commonbullet 05-11-2006 02:03

Re: c++ noob stuff
 
Quote:

Originally Posted by @$3.1415rin (Post 52627)
if you want to have the value of a character, you have to use 'a' instead of "A". the latter would give you a pointer to a char array containing an 'A' and a '\0'

Sorry, I didn't get it. I don't mean to get a char value..., I'm pretty stupid with this.

Anyway I found this:
Quote:

When using the STL with MSVC, you may get one or more error messages that look like:

C:\MSOE\stltest\stl2\stl2.cpp(302) : 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

This message results when MSVC tries to store debug information that includes long names generated by the template expansion process. The problem normally has no significant effect, and the message can be ignored. You may prefer to suppress this warning completely, as it may hide other (more important) error messages. To suppress the warning, add the following line near the top of your program source file:
#pragma warning(disable:4786)
out there:
http://www.msoe.edu/eecs/cese/resour...space%20issues

So, maybe it's an old implementation of stl on msvc. I've compiled a similar code with a newer msvc++ (express version) with no warnings. dev-c++ also compiles it with no problems...

mirv 05-11-2006 10:55

Re: c++ noob stuff
 
Looks to me like msvc++6.0 was trying to keep debug file sizes from getting too large. So wouldn't worry about it. dev-c++ uses the mingw library if I'm not mistaken, and express ed of msvc++ is based on msvc++8 I think.
It's not surprising really that a hash table of strings, using a string as the key, would generate some rather large template names either, and memory use is probably right up there with it (map implementation pending). Is there any other key you could use other than string?

commonbullet 05-11-2006 21:06

Re: c++ noob stuff
 
all right,

If I can use a delimited char array it would be ok.

I'd tried map<char*, char*> and had the same warnings...

thanks.

EDIT: I guess it won't work with something like <char[32], char[32]>, though.


All times are GMT +2. The time now is 01:42.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.