Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I really enjoy your site. You have a lot of helpful and friendly experts who contribute so willingly. Thank you for past (and future) technical advice..."

Geography

Where in the world do Tek-Tips members come from?
gennaropirozzi (Programmer)
25 Apr 12 13:48
hello,
in this code:

/*
    This file is a part of the OSC Library (Open Sound Code).
    Visit the OSC website at http://www.pvv.org/~thammer/HammerSound/osc/
    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[i];
    };
    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])[i];
    };


};

#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.
 

ArkM (IS/IT--Management)
25 Apr 12 16:36
This library C++ texts were prepared for Visual C++ compilers family (see http://www.hammersound.net/osc.html). 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?..
 
Prattaratt (TechnicalUser)
26 Apr 12 5:07
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.
ArkM (IS/IT--Management)
26 Apr 12 8:19
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!..
 
gennaropirozzi (Programmer)
26 Apr 12 16:20
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.
Helpful Member!  ArkM (IS/IT--Management)
27 Apr 12 1:49
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".
 
gennaropirozzi (Programmer)
27 Apr 12 8:21
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.
 
2ffat (Programmer)
27 Apr 12 12:20
Try "ios::std::setiosflags(ios::fixed)<<ios::std::setprecision(1)."
 

James P. Cottingham
I'm number 1,229!
I'm number 1,229!

ArkM (IS/IT--Management)
27 Apr 12 12:23
Add
#include <iomanip>
setiosflags and setprecision are declared in this header.
 
gennaropirozzi (Programmer)
27 Apr 12 16:28
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.
 
ArkM (IS/IT--Management)
28 Apr 12 1:09
>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...

 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close