Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compiler error 1

Status
Not open for further replies.

gennaropirozzi

Programmer
Apr 25, 2012
4
0
0
IT
hello,
in this code:

/*
This file is a part of the OSC Library (Open Sound Code).
Visit the OSC website at for the complete OSC library, the latest update, documentation,
user forum, etc.

Allthough the source code to the OSC Library is publicly available,
use and distribution of the OSC Library is governed by a license agreement.
The License Agreement can be found at the OSC website.
*/

#ifndef HCOMMANDLINELIBRARY_H
#define HCOMMANDLINELIBRARY_H

#include <map>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
#pragma warning( disable : 4786 ) // Disable debug warnings for long id-names

#include <assert.h>
#include <stdlib.h>

/*

A little note about using option prefix:
You still have to include the prefix when specifying the template
Syntax checking will be stricter

*/

class HCLL_Template
{
private:
map<string, int> m_optionMap; // m_option[label]=numParams

string m_optionPrefix;
bool m_useOptionPrefix;

public:
HCLL_Template()
{
m_useOptionPrefix=false;
};
HCLL_Template(const HCLL_Template &t)
{
operator=(t);
}
const HCLL_Template &operator=(const HCLL_Template &t)
{
m_optionMap=t.m_optionMap; // Hmmm...
m_optionPrefix=t.m_optionPrefix;
m_useOptionPrefix=t.m_useOptionPrefix;
return *this;
}

void setOptionPrefix(string pre)
{
m_useOptionPrefix=true;
m_optionPrefix=pre;
};

const string &getOptionPrefix()
{
return m_optionPrefix;
};


bool usingOptionPrefix()
{
return m_useOptionPrefix;
}

void addOption(const string &label, int numParams)
{
m_optionMap[label]=numParams;
}

bool optionExists(const string &label) const
{
return m_optionMap.find(label) != m_optionMap.end();
}


int operator[](const string &label)
{
if (optionExists(label))
return m_optionMap[label];
else
return 0;
// ERROR (but it is not reported, it is the caller's
// responsibility to check optionExists() first !
}

};

class HCLL_VarType
{
private:
string m_string;
public:
HCLL_VarType()
{
setString("");
}
HCLL_VarType(const string &str)
{
setString(str);
}
bool operator<(const HCLL_VarType &vt) const
{
return m_string<vt.getString();
};
bool operator==(const HCLL_VarType &vt) const
{
return m_string==vt.getString();
};

void setString(const string &str)
{
m_string=str;
}
const string & getString() const
{
return m_string;
}
long getInt() const
{
return atol(m_string.c_str());
}
double getFloat() const
{
return atof(m_string.c_str());
}
};

typedef vector<HCLL_VarType> HCLL_Option;
typedef map<string, HCLL_Option> HCLL_OptionMap; // HCLL_OptionMap["label"] = HCLL_Option
typedef vector<HCLL_VarType> HCLL_VarTypeArray;

#define HCLL_RESULT_OK 0
#define HCLL_RESULT_ERROR_TOO_FEW_OPTION_PARAMS 1
#define HCLL_RESULT_ERROR_UNRECOGNIZED_OPTION 2

typedef int HCLL_Result;

class HCLL_CommandLine
{
private:
HCLL_VarTypeArray m_progParam;
HCLL_OptionMap m_optionMap;
HCLL_Template m_template;
string m_lastOptionParsed;

public:
// må ha templaten først
void setTemplate(const HCLL_Template &t)
{
m_template=t;
}
HCLL_Result parse(int argc, char* argv[]);
const string &getLastOptionParsed() const
{
return m_lastOptionParsed;
}
void dump(); // for debugging
int getNumProgParams() const
{
return m_progParam.size();
};
const HCLL_VarType &getProgParam(int i) const
{
assert( (i>=0) && (i<m_progParam.size()) ); // should do proper error checking
return m_progParam;
};
int getNumOptions() const
{
return m_optionMap.size();
};
bool optionExists(const string &label) const
{
return m_optionMap.find(label) != m_optionMap.end();
}
int getNumOptionParams(const string &label)
{
// const_cast<HCLL_OptionMap>(m_optionMap);
return m_optionMap[label].size();
};
const HCLL_VarType &getOptionParam(const string &label, int i)
{
assert( (i>=0) && (i<m_optionMap[label].size()) ); // should do proper error checking
return (m_optionMap[label]);
};


};

#endif

I have this error:


Error: HCOMMANDLINELIBRARY.H(36,18):Too few arguments in template class name 'map'
Error: HCOMMANDLINELIBRARY.H(36,31):Declaration terminated incorrectly
Error: HCOMMANDLINELIBRARY.H(52,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(52,3):'m_optionMap' is not a member of 'HCLL_Template'
Error: HCOMMANDLINELIBRARY.H(77,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(82,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(89,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(139,33):Too few arguments in template class name 'map'
Error: HCOMMANDLINELIBRARY.H(139,49):Declaration terminated incorrectly
Error: HCOMMANDLINELIBRARY.H(152,28):Type name expected
Error: HCOMMANDLINELIBRARY.H(152,28):Declaration missing ;
Warn : HCOMMANDLINELIBRARY.H(174,3):Comparing signed and unsigned values
Error: HCOMMANDLINELIBRARY.H(179,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(183,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(188,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(192,3):Undefined symbol 'm_optionMap'
Warn : vector.h(985,31):Cannot create pre-compiled header: code in header
Error: HCOMMANDLINELIBRARY.H(77,29):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,26):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,28):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,29):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Too many error or warning messages


How to solve?
Thanks you.
 
This library C++ texts were prepared for Visual C++ compilers family (see For example, VC++ 9 compiles hcommandlinelibrary.h w/o errors. What compiler are you using?

What's a strange vector.h header name in diagnostic message?..
 
From what I can see, the STL supplied by Embarcadero with BCB XE2 has a map template definition like so (copied from the help):

Code:
template<class Key, class Ty, class Pr, class Alloc>
    class map;

As you can clearly see, it requires 4 arguments; Key, Ty, Pr and an allocator. You have only supplied 2 of those Arguments. Now if I recall correctly, the allocator is optional and if not supplied a default allocator will be used, but do not quote me on that. Since m_optionmap is not properly declared, as far as the compiler is concerned it does not exist. causing all the rest of your errors.
 
If Embarcadero library can't substitute map template parameter Predicate with less<Key> (see the C++ Standard), it's not C++ STL at all.

Q. How to solve?
A. Change compiler immediatly!..
 
I am using c++ borland 5.0.
The software is for borland c++ 4.5.
I now go to change compiler down to 4.5.
Can be this my problem?
Thanks you for support.
 
Change all map declarations like
Code:
map<string, int> m_optionMap;
to
Code:
map<string,int,less<string> > m_optionMap; // >space>
and try to compile again.

You have too old compiler with non-standard "STL".
 
Thanks you.
with map<string,int,less<string> > m_optionMap; // >space>
the problem go away.



I now have only 2 errors in this section:

int max, avail;
sfm.QueryStaticSampleMemorySize(max, avail);
cout<<std::setiosflags(ios::fixed)<<std::setprecision(1)
<<"Available: "<<(double)avail/(1024.0*1024.0)<<"MB, "
<<"Max: "<<(double)max/(1024.0*1024.0)<<"MB"<<endl;

if (caps.m_DevCaps & SFMANCAP_SOFTWARE_SYNTH_CAP)
cout<<" The device has a Software Synth engine"<<endl;
else
cout<<" The device has a Hardware Synth engine"<<endl;

// rom id, rom version
// synth emulations
};
};

I have this error:


Info :Compiling C:\p1\sf2load.cpp
Warn : string.h(549,3):Functions containing for are not expanded inline
Warn : string.h(557,3):Functions containing while are not expanded inline
Warn : string.h(563,3):Functions containing for are not expanded inline
Warn : string.h(575,3):Functions containing for are not expanded inline
Warn : string.cc(686,32):Comparing signed and unsigned values
Warn : tree.h(236,3):Functions containing while are not expanded inline
Warn : tree.h(241,3):Functions containing while are not expanded inline
Warn : tree.h(272,3):Functions containing while are not expanded inline
Warn : tree.h(300,3):Functions containing while are not expanded inline
Warn : tree.h(349,3):Functions containing while are not expanded inline
Warn : tree.h(377,3):Functions containing while are not expanded inline
Warn : tree.h(236,46):Functions containing while are not expanded inline
Warn : tree.h(241,46):Functions containing while are not expanded inline
Warn : tree.h(272,46):Functions containing while are not expanded inline
Warn : tree.h(300,46):Functions containing while are not expanded inline
Warn : tree.h(349,46):Functions containing while are not expanded inline
Warn : tree.h(377,46):Functions containing while are not expanded inline
Warn : HCOMMANDLINELIBRARY.H(139,47):Use '> >' for nested templates instead of '>>'
Warn : tree.h(236,29):Functions containing while are not expanded inline
Warn : tree.h(241,29):Functions containing while are not expanded inline
Warn : tree.h(272,29):Functions containing while are not expanded inline
Warn : tree.h(300,29):Functions containing while are not expanded inline
Warn : tree.h(349,29):Functions containing while are not expanded inline
Warn : tree.h(377,29):Functions containing while are not expanded inline
Warn : HCOMMANDLINELIBRARY.H(174,3):Comparing signed and unsigned values
Warn : HCOMMANDLINELIBRARY.H(192,3):Comparing signed and unsigned values
Warn : vector.h(985,31):Cannot create pre-compiled header: code in header
Warn : sf2load.cpp(168,12):Conversion may lose significant digits
Error: sf2load.cpp(453,27):'setiosflags' is not a member of 'std'
Error: sf2load.cpp(453,58):'setprecision' is not a member of 'std'
Warn : string.h(1880,44):Functions containing some return statements are not expanded inline



Have you any solution?
many thanks.
 
Try "ios::std::setiosflags(ios::fixed)<<ios::std::setprecision(1)."


James P. Cottingham
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Add
#include <iomanip>
setiosflags and setprecision are declared in this header.
 
Hello.
sfm.QueryStaticSampleMemorySize(max, avail);
// cout<<std::setiosflags(ios::fixed)<<std::setprecision(1)

cout<<ios::std::setiosflags(ios::fixed)<<ios::std::setprecision(1)

dont'works!!!!!
The compiler error is:

Error: sf2load.cpp(455,25):Qualifier 'std' is not a class or namespace name
Error: sf2load.cpp(455,27):Statement missing ;


Again:
#include <iomanip>

there is already!!!!!!!
Have yet solution????
REgards.
 
>Try "ios::std::setiosflags(ios::fixed)<<ios::std::setprecision(1)."
It's terrible!
1. std::ios hierarchy.
2. setprecision and setiosflags are declared in namespace std.
Discard these calls from the text: probably these standard functions were not implemented in your ancient compiler...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top