Code:
#include <iostream>
#include <map>
struct S
{
static const int x = 1;
};
using namespace std;
int main(void)
{
map<int, string> mapa;
mapa[S::x] = "zdravo svete";
cout<<mapa[S::x];
return 0;
}
#include <iostream>
#include <map>
struct S
{
static const int x = 1;
};
using namespace std;
int main(void)
{
map<int, string> mapa;
mapa[S::x] = "zdravo svete";
cout<<mapa[S::x];
return 0;
}
Ako linije 14 i 15 zamenim sa
Code:
mapa[(int)S::x] = "zdravo svete";
cout<<mapa[(int)S::x];
mapa[(int)S::x] = "zdravo svete";
cout<<mapa[(int)S::x];
onda je prevođenje i linkovanje uspešno.
Najčudniije od svega mi je što primer iz Boost biblioteke (<boost dir>\libs\spirit\example\fundamental\ast_calc.cpp) uspešno linkuje sa libstdc++ bibliotekom a sa STLport bibliotekom javlja undefined reference to calculator::integerID, factorID, termID, expressionID. Problematičan deo koda u ovom primeru je
Code:
std::map<parser_id, std::string> rule_names;
rule_names[calculator::integerID] = "integer";
rule_names[calculator::factorID] = "factor";
rule_names[calculator::termID] = "term";
rule_names[calculator::expressionID] = "expression";
std::map<parser_id, std::string> rule_names;
rule_names[calculator::integerID] = "integer";
rule_names[calculator::factorID] = "factor";
rule_names[calculator::termID] = "term";
rule_names[calculator::expressionID] = "expression";
Posle konverzije u int uspeva i linkovanje sa STLport bibliotekom. Ne mogu da primetim razliku između ovog koda iz boost biblioteke i onog koji sam gore naveo. Zašto ovaj kod uspešno linkuje sa libstdc++ a neće sa STLport i zašto gore navedeni kod neće da linkuje ni sa libstdc++ bibliotekom?
[Ovu poruku je menjao Lazar-I dana 27.01.2008. u 00:43 GMT+1]