Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / May 2005



Tip: Looking for answers? Try searching our database.

Operator << broken?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sensei - 27 May 2005 23:00 GMT
Hi, I'm trying to port a software on osx 10.4 (gcc 4). I find it
difficult to compile this sw, which I consider a piece of junk...
anyway, at first I had:

PlasmArray.h: In member function `void PlasmArray<T>::clear()':
PlasmArray.h:68: error: there are no arguments to 'begin' that depend on
a template parameter, so a declaration of 'begin' must be available
PlasmArray.h:68: error: (if you use `-fpermissive', G++ will accept your
code, but allowing the use of an undeclared name is deprecated)
PlasmArray.h:68: error: there are no arguments to 'end' that depend on a
template parameter, so a declaration of 'end' must be available

Being PlasmArray:

template<class T>
class PlasmArray: public std::deque<T>
{
public:

so, in a function that used directly begin() and end(), I had to use
this->begin() and this->end() .... still wondering why...

Fixed that, in boolalgo.cpp if I include fstream, then I get:

/usr/include/gcc/darwin/4.0/c++/bits/fstream.tcc: In member function
`virtual typename std::basic_filebuf<_CharT, _Traits>::int_type
std::basic_filebuf<_CharT, _Traits>::underflow()':
/usr/include/gcc/darwin/4.0/c++/bits/fstream.tcc:277: error: expected
unqualified-id before '(' token
/usr/include/gcc/darwin/4.0/c++/bits/fstream.tcc: In member function
`virtual std::streamsize std::basic_filebuf<_CharT,
_Traits>::xsputn(const _CharT*, std::streamsize)':
/usr/include/gcc/darwin/4.0/c++/bits/fstream.tcc:585: error: expected
unqualified-id before '(' token
make[2]: *** [boolalgo.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

The only way to fix it, and I don't know why, is to delete the directive
#include <fstream>. Then I have:

=== boolalgo.cpp

#include "bsp.h"
//#include <fstream>
#include <queue>
#include <stack>

using namespace std;
...
void save_bsp_tree( ofstream& of, bsptnodeptr p )
{
        if( p->type == bsptnode::CUT ) {
                of << (p->cut) << endl;
                save_bsp_tree( of, p->below );
                save_bsp_tree( of, p->above );
        }
        else {
                if( p->type == bsptnode::IN )
                        of << "IN" << endl;
                else if( p->type == bsptnode::OUT )
                        of << "OUT" << endl;
                else
                        of << "!UNDEFINED!" << endl;
        }
}

=== bsp.h

#ifndef __BSP_H
#define __BSP_H
#ifdef WIN32
#pragma warning(disable:4786)
#endif
#include "GeneralDef.h"

class bsptnode {
        friend class bspt;

public:
        enum Type {
                CUT = 0x00,
                ...
        };
        enum {
                UNDEFINED_CUT = unsigned(-1)
        };
        Type            type;
        unsigned        cut;
        bsptnodeptr     below;
        bsptnodeptr     above;
private:
        bsptnode( const bsptnode& );
        bsptnode& operator=( const bsptnode& );
public:
        bsptnode():type(OUT),cut(UNDEFINED_CUT),below(0),above(0) {}
        bsptnode(Type t):type(t),cut(UNDEFINED_CUT),below(0),above(0) {}
        bsptnode(Type t, unsigned c):type(t),cut(c),below(0),above(0) {}

        ~bsptnode() {
                if (above)
                        delete above;
                if (below)
                        delete below;
        }
};

=== GeneralDef.h

#ifndef _GENERAL_DEFS_H__
#define _GENERAL_DEFS_H__
#ifdef WIN32
#pragma warning (disable:4786)
#endif
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <math.h>
#include <assert.h>

class bspt;
class bsptnode;
class hyperplanes;
class ISystem;
class equation;

typedef bspt* bsptptr;

typedef bsptnode* bsptnodeptr;

===END===

Compiling it:

boolalgo.cpp: In function `void save_bsp_tree(std::ofstream&, bsptnode*)':
boolalgo.cpp:70: error: no match for 'operator<<' in 'of <<
p->bsptnode::cut'
PlasmVector.h:143: note: candidates are: std::ostream&
operator<<(std::ostream&, const PlasmVector&)
matrix.h:96: note:                 std::ostream&
operator<<(std::ostream&, const matrix&)
PlasmMatrix.h:69: note:                 std::ostream&
operator<<(std::ostream&, const PlasmMatrix&)
PlasmID.h:52: note:                 std::ostream&
operator<<(std::ostream&, const PlasmID&)
...
PlasmArray.h:136: note:                 std::basic_ostream<char,
std::char_traits<char> >& operator<<(std::basic_ostream<char,
std::char_traits<char> >&, const PlasmArray<PlasmHyperPlane>&)
GeneralDef.h:184: note:                 std::ostream&
operator<<(std::ostream&, const PlasmSet&)
PlasmFastArray.h:248: note:                 std::basic_ostream<char,
std::char_traits<char> >& operator<<(std::basic_ostream<char,
std::char_traits<char> >&, const PlasmFastArray<PlasmIndex>&)
bsp.h:95: note:                 std::ostream& operator<<(std::ostream&,
const equation&)
bsp.h:228: note:                 std::ostream& operator<<(std::ostream&,
bspt&)
bsp.h:251: note:                 std::ostream& operator<<(std::ostream&,
ISystemData&)
bsp.h:303: note:                 std::ostream& operator<<(std::ostream&,
ISystem&)
...
GeneralDef.h:184: note:                 std::ostream&
operator<<(std::ostream&, const PlasmSet&)
PlasmFastArray.h:248: note:                 std::basic_ostream<char,
std::char_traits<char> >& operator<<(std::basic_ostream<char,
std::char_traits<char> >&, const PlasmFastArray<PlasmIndex>&)
bsp.h:95: note:                 std::ostream& operator<<(std::ostream&,
const equation&)
bsp.h:228: note:                 std::ostream& operator<<(std::ostream&,
bspt&)
bsp.h:251: note:                 std::ostream& operator<<(std::ostream&,
ISystemData&)
bsp.h:303: note:                 std::ostream& operator<<(std::ostream&,
ISystem&)

***continuing reading I find also:

boolalgo.cpp:78: error: no match for 'operator<<' in 'of << "OUT"'
PlasmVector.h:143: note: candidates are: std::ostream&
operator<<(std::ostream&, const PlasmVector&)
matrix.h:96: note:                 std::ostream&
operator<<(std::ostream&, const matrix&)
PlasmMatrix.h:69: note:                 std::ostream&
operator<<(std::ostream&, const PlasmMatrix&)
...
boolalgo.cpp:80: error: no match for 'operator<<' in 'of << "!UNDEFINED!"'
PlasmVector.h:143: note: candidates are: std::ostream&
operator<<(std::ostream&, const PlasmVector&)
...

***and at last:

boolalgo.cpp: In function `void save_bsp(char*, bsptnode*, hyperplanes)':
boolalgo.cpp:176: error: variable 'std::ofstream of' has initializer but
incomplete type
make[2]: *** [boolalgo.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
sensei:plasm$
John Whorfin - 28 May 2005 00:28 GMT
> so, in a function that used directly begin() and end(), I had to use
> this->begin() and this->end() .... still wondering why...

It's the way C++ is supposed to work.  Look up "two-phase name lookup".

> Fixed that, in boolalgo.cpp if I include fstream, then I get:
...
> /usr/include/gcc/darwin/4.0/c++/bits/fstream.tcc:277: error: expected
> unqualified-id before '(' token

Line 277 has a call to std::min().  Given the ordering of the
includes below I suspect bsp.h is defining min as a macro. Try
moving the fstream include before bsp.h

> === boolalgo.cpp
>
> #include "bsp.h"
> //#include <fstream>
> #include <queue>
> #include <stack>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.