public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Compile errors
@ 2005-03-29  0:06 Parms singh
  2005-03-29  6:23 ` corey taylor
  2005-03-29 12:40 ` Eljay Love-Jensen
  0 siblings, 2 replies; 17+ messages in thread
From: Parms singh @ 2005-03-29  0:06 UTC (permalink / raw)
  To: Eljay Love-Jensen, corey taylor; +Cc: gcc-help

Hello Eljay,

Okay, I took your advise and changed the headers
carefully to the point that they are c++ complaint
headers.

The only difference between my original posting and
what I now have is that I have the following line
after the includes in the cc file:

using namespace std;
using __gnu_cxx::hash;

I get the exact same errors as my original posting.

Sorry about the bother.

Parms



--- Eljay Love-Jensen <eljay@adobe.com> wrote:
> Hi Parms,
> 
> I strongly recommend avoiding <hash_map.h>, and
> instead recommend <ext/hash_map> which has symbols
> in the __gnu_cxx namespace.
> 
> If you do want to use the backward compatibility
> header files, make sure you do not co-mingle
> backward compatibility header files with C++
> compliant header files.  I suspect that may cause
> problems.  (For instance, if you use <hash_map.h>,
> then you should use the non-compliant <iostream.h>
> and not the C++ compliant <iostream>.)
> 
> Otherwise you may run into symbol collisions, such
> as the one you are running into with the swap symbol
> already being used.
> 
> HTH,
> --Eljay
> 
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Compile errors
  2005-03-29  0:06 Compile errors Parms singh
@ 2005-03-29  6:23 ` corey taylor
  2005-03-29 12:40 ` Eljay Love-Jensen
  1 sibling, 0 replies; 17+ messages in thread
From: corey taylor @ 2005-03-29  6:23 UTC (permalink / raw)
  To: Parms singh; +Cc: Eljay Love-Jensen, gcc-help

I'm pretty sure that won't fix the error unless the using statements
in the cc file are before where you include the header that uses hash.

You might just try __gnu_cxx::hash<int> in your code instead.

corey


On Mon, 28 Mar 2005 16:04:22 -0800 (PST), Parms singh
<list_track@yahoo.com> wrote:
> Hello Eljay,
> 
> Okay, I took your advise and changed the headers
> carefully to the point that they are c++ complaint
> headers.
> 
> The only difference between my original posting and
> what I now have is that I have the following line
> after the includes in the cc file:
> 
> using namespace std;
> using __gnu_cxx::hash;
> 
> I get the exact same errors as my original posting.
> 
> Sorry about the bother.
> 
> Parms
> 
> --- Eljay Love-Jensen <eljay@adobe.com> wrote:
> > Hi Parms,
> >
> > I strongly recommend avoiding <hash_map.h>, and
> > instead recommend <ext/hash_map> which has symbols
> > in the __gnu_cxx namespace.
> >
> > If you do want to use the backward compatibility
> > header files, make sure you do not co-mingle
> > backward compatibility header files with C++
> > compliant header files.  I suspect that may cause
> > problems.  (For instance, if you use <hash_map.h>,
> > then you should use the non-compliant <iostream.h>
> > and not the C++ compliant <iostream>.)
> >
> > Otherwise you may run into symbol collisions, such
> > as the one you are running into with the swap symbol
> > already being used.
> >
> > HTH,
> > --Eljay
> >
> >
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Compile errors
  2005-03-29  0:06 Compile errors Parms singh
  2005-03-29  6:23 ` corey taylor
@ 2005-03-29 12:40 ` Eljay Love-Jensen
  1 sibling, 0 replies; 17+ messages in thread
From: Eljay Love-Jensen @ 2005-03-29 12:40 UTC (permalink / raw)
  To: Parms singh; +Cc: gcc-help

Hi Parms,

>I get the exact same errors as my original posting.

I modified your original posting as I had suggested, stubbed out the missing .h files, and it compiles for me without complaint.

Please post a current complete sample .h and .cc file that exhibit the problematic behavior you are experiencing.

Your original .h and .cc file contained header files that you did not provide.  That's an additional unknown when trying to diagnose the situation you are experiencing.

Thanks,
--Eljay

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Compile errors
@ 2005-03-29 17:36 Parms singh
  0 siblings, 0 replies; 17+ messages in thread
From: Parms singh @ 2005-03-29 17:36 UTC (permalink / raw)
  To: Eljay Love-Jensen; +Cc: gcc-help

Hello Eljay,

I finally got it to run. The change I made was the
following:
__gnu_cxx::hash_map<int, std::pair<int,HTEntry>,
__gnu_cxx::hash<int>, __gnu_cxx::equal_to<int> >HMap;

The code is part of a rather large system ... so
hopefully, this should get me started. 
Thanks to both you and Corey for your time and useful
comments and tips.

Parms
--- Eljay Love-Jensen <eljay@adobe.com> wrote:
> Hi Parms,
> 
> >I get the exact same errors as my original posting.
> 
> I modified your original posting as I had suggested,
> stubbed out the missing .h files, and it compiles
> for me without complaint.
> 
> Please post a current complete sample .h and .cc
> file that exhibit the problematic behavior you are
> experiencing.
> 
> Your original .h and .cc file contained header files
> that you did not provide.  That's an additional
> unknown when trying to diagnose the situation you
> are experiencing.
> 
> Thanks,
> --Eljay
> 
> 


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Compile errors
  2005-03-28 22:55 Parms singh
@ 2005-03-28 23:03 ` Eljay Love-Jensen
  0 siblings, 0 replies; 17+ messages in thread
From: Eljay Love-Jensen @ 2005-03-28 23:03 UTC (permalink / raw)
  To: Parms singh, corey taylor; +Cc: gcc-help

Hi Parms,

I strongly recommend avoiding <hash_map.h>, and instead recommend <ext/hash_map> which has symbols in the __gnu_cxx namespace.

If you do want to use the backward compatibility header files, make sure you do not co-mingle backward compatibility header files with C++ compliant header files.  I suspect that may cause problems.  (For instance, if you use <hash_map.h>, then you should use the non-compliant <iostream.h> and not the C++ compliant <iostream>.)

Otherwise you may run into symbol collisions, such as the one you are running into with the swap symbol already being used.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Compile errors
@ 2005-03-28 22:55 Parms singh
  2005-03-28 23:03 ` Eljay Love-Jensen
  0 siblings, 1 reply; 17+ messages in thread
From: Parms singh @ 2005-03-28 22:55 UTC (permalink / raw)
  To: Eljay Love-Jensen, corey taylor; +Cc: gcc-help

Hello Eljay,

Thanks a bunch for catching the namespace problem.

I went back to using hash_map.h, which gives me a
couple of warnings for using deprecated headers (I can
live with that), but I can't correct one error. This
comes from 

In file included from
/usr/include/c++/3.2.2/backward/hash_map.h:60,
                 from qd.h:71,
                 from qd.cc:68:
/usr/include/c++/3.2.2/backward/algobase.h:68: `swap'
is already declared in this scope

If I can get rid of this, I am done.

thanks again
Parms



--- Eljay Love-Jensen <eljay@adobe.com> wrote:
> Hi Parms,
> 
> I think hash is in __gnu_cxx namespace.
> 
> Try this instead:
> using __gnu_cxx::hash;
> 
> Also, I suggest you do not put using statements in
> your header files.  Bad mojo.
> 
> --Eljay
> 
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Compile errors
  2005-03-28 22:15   ` Eljay Love-Jensen
@ 2005-03-28 22:51     ` corey taylor
  0 siblings, 0 replies; 17+ messages in thread
From: corey taylor @ 2005-03-28 22:51 UTC (permalink / raw)
  To: Eljay Love-Jensen; +Cc: Parms singh, gcc-help

Well, the hash_fun.h header declares it in that namespace, which I
actually just told him to use.

std_ version does declare it in stl namespace but I don't know why it
doesn't find it.

corey


On Mon, 28 Mar 2005 16:14:47 -0600, Eljay Love-Jensen <eljay@adobe.com> wrote:
> Hi Parms,
> 
> I think hash is in __gnu_cxx namespace.
> 
> Try this instead:
> using __gnu_cxx::hash;
> 
> Also, I suggest you do not put using statements in your header files.  Bad mojo.
> 
> --Eljay
> 
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Compile errors
  2005-03-28 22:13 ` Parms singh
@ 2005-03-28 22:15   ` Eljay Love-Jensen
  2005-03-28 22:51     ` corey taylor
  0 siblings, 1 reply; 17+ messages in thread
From: Eljay Love-Jensen @ 2005-03-28 22:15 UTC (permalink / raw)
  To: Parms singh, corey taylor; +Cc: gcc-help

Hi Parms,

I think hash is in __gnu_cxx namespace.

Try this instead:
using __gnu_cxx::hash;

Also, I suggest you do not put using statements in your header files.  Bad mojo.

--Eljay

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Compile errors
@ 2005-03-28 22:13 ` Parms singh
  2005-03-28 22:15   ` Eljay Love-Jensen
  0 siblings, 1 reply; 17+ messages in thread
From: Parms singh @ 2005-03-28 22:13 UTC (permalink / raw)
  To: corey taylor; +Cc: gcc-help

Hello Corey:

When I put the 'using std::hash;' line in the .h file,
I get an additional error that says
'hash' not declared (as shown below). The line number
corresponds to the new line.

On moving the 'using std::hash' line to the .cc file,
the error is exactly as before (only the above
mentioned error is missing). 

I read in a couple of postings that such declarations
ought to be made in the .cc file.

Parms

In my .h file:
#include <ext/stl_hash_fun.h>
#include <ext/hash_map>
using std::hash;

class HTEntry {
public:
        double time;
        double ttl;
};
                                                      
                         
typedef hash_map<int, pair<int,HTEntry>, hash<int>,
equal_to<int> > HMap;
                                                      
                         
class Hash_Table
{
public:
        void increment(int, double, double);
        int lookup(int,double,double);
        int findsize(double,bool);
        int estimate_hit(double);
protected:
        HMap flows;
};



In the .cc file:
#include <iostream>
#include <sstream>
#include <cmath>
#include <valarray>
#include <string>
#include <sys/types.h>
#include "config.h"
#include "template.h"
#include "flags.h"
#include "delay.h"
#include "rd.h"

using namespace std;

void Hash_Table::increment(int id, double t_now,
double ttl)
{
        HMap::iterator iter;
        iter=flows.find(id);
        double timelived, thresh;
        int hits;
 // bunch of stuff       
}

//other functions that I leave out.

Errors:
In file included from qd.cc:78: 
qd.h:74: 'hash' not declared
qd.h:154: `hash' was not declared in this scope
qd.h:154: parse error before `>' token
qd.h:173: 'HMap' is used as a type, but is not defined
as a type.
qd.cc: In member function `void
Hash_Table::increment(int, double, double)':
qd.cc:1232: `HMap' undeclared (first use this
function)
qd.cc:1232: (Each undeclared identifier is reported
only once for each
   function it appears in.)
qd.cc:1232: parse error before `::' token
qd.cc:1233: `iter' undeclared (first use this
function)
qd.cc:1233: `flows' undeclared (first use this
function)
qd.cc: In member function `int
Hash_Table::findsize(double, bool)':
qd.cc:1274: parse error before `::' token
qd.cc: In member function `int Hash_Table::lookup(int,
double, double)':
qd.cc:1360: parse error before `::' token
make: *** [qd.o] Error 1

Similar errors for other functions removed for
simplicity.

Any help is appreciated.

--- corey taylor <corey.taylor@gmail.com> wrote:
> Parms,
> 
>   Can you post what you have now?
> 
> corey
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Compile errors
  2005-03-28 20:50   ` Parms singh
@ 2005-03-28 22:01     ` corey taylor
  0 siblings, 0 replies; 17+ messages in thread
From: corey taylor @ 2005-03-28 22:01 UTC (permalink / raw)
  To: Parms singh; +Cc: gcc-help

Parms,

  Can you post what you have now?

corey


On Mon, 28 Mar 2005 12:48:03 -0800 (PST), Parms singh
<list_track@yahoo.com> wrote:
> Hello Corey,
> 
> I left the stl_hash_fun.h as is. I had removed it to
> see if it was 'hash' was declared in any other file.
> 
> I added the using statement as you mentioned. However,
> I continue to get the same error(s).
> 
> Parms
> --- corey taylor <corey.taylor@gmail.com> wrote:
> 
> > Why would you remove the file that declares
> > std::hash?
> >
> > You need to leave that in and simply add the using
> > statement.
> >
> > corey
> >
> >
> > On Mon, 28 Mar 2005 09:59:54 -0800 (PST), Parms
> > singh
> > <list_track@yahoo.com> wrote:
> > > Corey,
> > >
> > > I did a couple of things:
> > > - Added the following as you suggested:
> > >   using std::hash; in the .cc file.
> > >
> > > - Removed stl_hash_fun.h and tried to compile.
> > >
> > > I get the exact same errors as my original posting
> > in
> > > both the cases.
> > >
> > > Parms
> > > --- corey taylor <corey.taylor@gmail.com> wrote:
> > > > Parms,
> > > >
> > > >   You are using the stl_hash_fun.h header file
> > so
> > > > hash is declared
> > > > inside the stl namespace.  You need to fully
> > qualify
> > > > it with the std::
> > > > namespace or add
> > > >
> > > > using std::hash;
> > > >
> > > > Beneath the includes.
> > > >
> > > > corey
> > > >
> 
> __________________________________
> Do you Yahoo!?
> Make Yahoo! your home page
> http://www.yahoo.com/r/hs
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Compile errors
  2005-03-28 19:55 ` corey taylor
@ 2005-03-28 20:50   ` Parms singh
  2005-03-28 22:01     ` corey taylor
  0 siblings, 1 reply; 17+ messages in thread
From: Parms singh @ 2005-03-28 20:50 UTC (permalink / raw)
  To: corey taylor; +Cc: gcc-help

Hello Corey,

I left the stl_hash_fun.h as is. I had removed it to
see if it was 'hash' was declared in any other file.

I added the using statement as you mentioned. However,
I continue to get the same error(s).

Parms
--- corey taylor <corey.taylor@gmail.com> wrote:

> Why would you remove the file that declares
> std::hash?
> 
> You need to leave that in and simply add the using
> statement.
> 
> corey
> 
> 
> On Mon, 28 Mar 2005 09:59:54 -0800 (PST), Parms
> singh
> <list_track@yahoo.com> wrote:
> > Corey,
> > 
> > I did a couple of things:
> > - Added the following as you suggested:
> >   using std::hash; in the .cc file.
> > 
> > - Removed stl_hash_fun.h and tried to compile.
> > 
> > I get the exact same errors as my original posting
> in
> > both the cases.
> > 
> > Parms
> > --- corey taylor <corey.taylor@gmail.com> wrote:
> > > Parms,
> > >
> > >   You are using the stl_hash_fun.h header file
> so
> > > hash is declared
> > > inside the stl namespace.  You need to fully
> qualify
> > > it with the std::
> > > namespace or add
> > >
> > > using std::hash;
> > >
> > > Beneath the includes.
> > >
> > > corey
> > >



		
__________________________________ 
Do you Yahoo!? 
Make Yahoo! your home page 
http://www.yahoo.com/r/hs

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Compile errors
  2005-03-28 18:57 Parms singh
@ 2005-03-28 19:55 ` corey taylor
  2005-03-28 20:50   ` Parms singh
  0 siblings, 1 reply; 17+ messages in thread
From: corey taylor @ 2005-03-28 19:55 UTC (permalink / raw)
  To: Parms singh; +Cc: gcc-help

Why would you remove the file that declares std::hash?

You need to leave that in and simply add the using statement.

corey


On Mon, 28 Mar 2005 09:59:54 -0800 (PST), Parms singh
<list_track@yahoo.com> wrote:
> Corey,
> 
> I did a couple of things:
> - Added the following as you suggested:
>   using std::hash; in the .cc file.
> 
> - Removed stl_hash_fun.h and tried to compile.
> 
> I get the exact same errors as my original posting in
> both the cases.
> 
> Parms
> --- corey taylor <corey.taylor@gmail.com> wrote:
> > Parms,
> >
> >   You are using the stl_hash_fun.h header file so
> > hash is declared
> > inside the stl namespace.  You need to fully qualify
> > it with the std::
> > namespace or add
> >
> > using std::hash;
> >
> > Beneath the includes.
> >
> > corey
> >
> > On Mon, 28 Mar 2005 09:29:10 -0800 (PST), Parms
> > singh
> > <list_track@yahoo.com> wrote:
> > > Hello,
> > >
> > > I am running gcc version 3.2.2 20030222 (Red Hat
> > Linux
> > > 3.2.2-5).
> > >
> > > I am a relative newbee to c++ (haven't used it in
> > a
> > > while).
> > >
> > > In my .h file:
> > > #include <ext/stl_hash_fun.h>
> > > #include <ext/hash_map>
> > >
> > > class HTEntry {
> > > public:
> > >         double time;
> > >         double ttl;
> > > };
> > >
> > > typedef hash_map<int, pair<int,HTEntry>,
> > hash<int>,
> > > equal_to<int> > HMap;
> > >
> > > class Hash_Table
> > > {
> > > public:
> > >         void increment(int, double, double);
> > >         int lookup(int,double,double);
> > >         int findsize(double,bool);
> > >         int estimate_hit(double);
> > > protected:
> > >         HMap flows;
> > > };
> > >
> > > In the .cc file:
> > > #include <iostream>
> > > #include <sstream>
> > > #include <cmath>
> > > #include <valarray>
> > > #include <string>
> > > #include <sys/types.h>
> > > #include "config.h"
> > > #include "template.h"
> > > #include "flags.h"
> > > #include "delay.h"
> > > #include "rd.h"
> > >
> > > using namespace std;
> > >
> > > void Hash_Table::increment(int id, double t_now,
> > > double ttl)
> > > {
> > >         HMap::iterator iter;
> > >         iter=flows.find(id);
> > >         double timelived, thresh;
> > >         int hits;
> > >  // bunch of stuff
> > > }
> > >
> > > //other functions that I leave out.
> > >
> > > Errors:
> > > In file included from qd.cc:78:
> > > qd.h:154: `hash' was not declared in this scope
> > > qd.h:154: parse error before `>' token
> > > qd.h:173: 'HMap' is used as a type, but is not
> > defined
> > > as a type.
> > > qd.cc: In member function `void
> > > Hash_Table::increment(int, double, double)':
> > > qd.cc:1232: `HMap' undeclared (first use this
> > > function)
> > > qd.cc:1232: (Each undeclared identifier is
> > reported
> > > only once for each
> > >    function it appears in.)
> > > qd.cc:1232: parse error before `::' token
> > > qd.cc:1233: `iter' undeclared (first use this
> > > function)
> > > qd.cc:1233: `flows' undeclared (first use this
> > > function)
> > > qd.cc: In member function `int
> > > Hash_Table::findsize(double, bool)':
> > > qd.cc:1274: parse error before `::' token
> > > qd.cc: In member function `int
> > Hash_Table::lookup(int,
> > > double, double)':
> > > qd.cc:1360: parse error before `::' token
> > > make: *** [qd.o] Error 1
> > >
> > > Similar errors for other functions removed for
> > > simplicity.
> > >
> > > Any help is appreciated.
> > >
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > Yahoo! Small Business - Try our new resources
> > site!
> > > http://smallbusiness.yahoo.com/resources/
> > >
> >
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Compile errors
@ 2005-03-28 18:57 Parms singh
  2005-03-28 19:55 ` corey taylor
  0 siblings, 1 reply; 17+ messages in thread
From: Parms singh @ 2005-03-28 18:57 UTC (permalink / raw)
  To: corey taylor; +Cc: gcc-help

Corey,

I did a couple of things:
- Added the following as you suggested:
  using std::hash; in the .cc file.

- Removed stl_hash_fun.h and tried to compile. 

I get the exact same errors as my original posting in
both the cases.

Parms
--- corey taylor <corey.taylor@gmail.com> wrote:
> Parms,
> 
>   You are using the stl_hash_fun.h header file so
> hash is declared
> inside the stl namespace.  You need to fully qualify
> it with the std::
> namespace or add
> 
> using std::hash; 
> 
> Beneath the includes.
> 
> corey
> 
> On Mon, 28 Mar 2005 09:29:10 -0800 (PST), Parms
> singh
> <list_track@yahoo.com> wrote:
> > Hello,
> > 
> > I am running gcc version 3.2.2 20030222 (Red Hat
> Linux
> > 3.2.2-5).
> > 
> > I am a relative newbee to c++ (haven't used it in
> a
> > while).
> > 
> > In my .h file:
> > #include <ext/stl_hash_fun.h>
> > #include <ext/hash_map>
> > 
> > class HTEntry {
> > public:
> >         double time;
> >         double ttl;
> > };
> > 
> > typedef hash_map<int, pair<int,HTEntry>,
> hash<int>,
> > equal_to<int> > HMap;
> > 
> > class Hash_Table
> > {
> > public:
> >         void increment(int, double, double);
> >         int lookup(int,double,double);
> >         int findsize(double,bool);
> >         int estimate_hit(double);
> > protected:
> >         HMap flows;
> > };
> > 
> > In the .cc file:
> > #include <iostream>
> > #include <sstream>
> > #include <cmath>
> > #include <valarray>
> > #include <string>
> > #include <sys/types.h>
> > #include "config.h"
> > #include "template.h"
> > #include "flags.h"
> > #include "delay.h"
> > #include "rd.h"
> > 
> > using namespace std;
> > 
> > void Hash_Table::increment(int id, double t_now,
> > double ttl)
> > {
> >         HMap::iterator iter;
> >         iter=flows.find(id);
> >         double timelived, thresh;
> >         int hits;
> >  // bunch of stuff
> > }
> > 
> > //other functions that I leave out.
> > 
> > Errors:
> > In file included from qd.cc:78:
> > qd.h:154: `hash' was not declared in this scope
> > qd.h:154: parse error before `>' token
> > qd.h:173: 'HMap' is used as a type, but is not
> defined
> > as a type.
> > qd.cc: In member function `void
> > Hash_Table::increment(int, double, double)':
> > qd.cc:1232: `HMap' undeclared (first use this
> > function)
> > qd.cc:1232: (Each undeclared identifier is
> reported
> > only once for each
> >    function it appears in.)
> > qd.cc:1232: parse error before `::' token
> > qd.cc:1233: `iter' undeclared (first use this
> > function)
> > qd.cc:1233: `flows' undeclared (first use this
> > function)
> > qd.cc: In member function `int
> > Hash_Table::findsize(double, bool)':
> > qd.cc:1274: parse error before `::' token
> > qd.cc: In member function `int
> Hash_Table::lookup(int,
> > double, double)':
> > qd.cc:1360: parse error before `::' token
> > make: *** [qd.o] Error 1
> > 
> > Similar errors for other functions removed for
> > simplicity.
> > 
> > Any help is appreciated.
> > 
> > 
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Small Business - Try our new resources
> site!
> > http://smallbusiness.yahoo.com/resources/
> >
> 


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Compile errors
  2005-03-28 17:41 Parms singh
@ 2005-03-28 18:00 ` corey taylor
  0 siblings, 0 replies; 17+ messages in thread
From: corey taylor @ 2005-03-28 18:00 UTC (permalink / raw)
  To: Parms singh; +Cc: gcc-help

Parms,

  You are using the stl_hash_fun.h header file so hash is declared
inside the stl namespace.  You need to fully qualify it with the std::
namespace or add

using std::hash; 

Beneath the includes.

corey

On Mon, 28 Mar 2005 09:29:10 -0800 (PST), Parms singh
<list_track@yahoo.com> wrote:
> Hello,
> 
> I am running gcc version 3.2.2 20030222 (Red Hat Linux
> 3.2.2-5).
> 
> I am a relative newbee to c++ (haven't used it in a
> while).
> 
> In my .h file:
> #include <ext/stl_hash_fun.h>
> #include <ext/hash_map>
> 
> class HTEntry {
> public:
>         double time;
>         double ttl;
> };
> 
> typedef hash_map<int, pair<int,HTEntry>, hash<int>,
> equal_to<int> > HMap;
> 
> class Hash_Table
> {
> public:
>         void increment(int, double, double);
>         int lookup(int,double,double);
>         int findsize(double,bool);
>         int estimate_hit(double);
> protected:
>         HMap flows;
> };
> 
> In the .cc file:
> #include <iostream>
> #include <sstream>
> #include <cmath>
> #include <valarray>
> #include <string>
> #include <sys/types.h>
> #include "config.h"
> #include "template.h"
> #include "flags.h"
> #include "delay.h"
> #include "rd.h"
> 
> using namespace std;
> 
> void Hash_Table::increment(int id, double t_now,
> double ttl)
> {
>         HMap::iterator iter;
>         iter=flows.find(id);
>         double timelived, thresh;
>         int hits;
>  // bunch of stuff
> }
> 
> //other functions that I leave out.
> 
> Errors:
> In file included from qd.cc:78:
> qd.h:154: `hash' was not declared in this scope
> qd.h:154: parse error before `>' token
> qd.h:173: 'HMap' is used as a type, but is not defined
> as a type.
> qd.cc: In member function `void
> Hash_Table::increment(int, double, double)':
> qd.cc:1232: `HMap' undeclared (first use this
> function)
> qd.cc:1232: (Each undeclared identifier is reported
> only once for each
>    function it appears in.)
> qd.cc:1232: parse error before `::' token
> qd.cc:1233: `iter' undeclared (first use this
> function)
> qd.cc:1233: `flows' undeclared (first use this
> function)
> qd.cc: In member function `int
> Hash_Table::findsize(double, bool)':
> qd.cc:1274: parse error before `::' token
> qd.cc: In member function `int Hash_Table::lookup(int,
> double, double)':
> qd.cc:1360: parse error before `::' token
> make: *** [qd.o] Error 1
> 
> Similar errors for other functions removed for
> simplicity.
> 
> Any help is appreciated.
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Compile errors
@ 2005-03-28 17:41 Parms singh
  2005-03-28 18:00 ` corey taylor
  0 siblings, 1 reply; 17+ messages in thread
From: Parms singh @ 2005-03-28 17:41 UTC (permalink / raw)
  To: gcc-help

Hello,

I am running gcc version 3.2.2 20030222 (Red Hat Linux
3.2.2-5).

I am a relative newbee to c++ (haven't used it in a
while).

In my .h file:
#include <ext/stl_hash_fun.h>
#include <ext/hash_map>

class HTEntry {
public:
        double time;
        double ttl;
};
                                                      
                         
typedef hash_map<int, pair<int,HTEntry>, hash<int>,
equal_to<int> > HMap;
                                                      
                         
class Hash_Table
{
public:
        void increment(int, double, double);
        int lookup(int,double,double);
        int findsize(double,bool);
        int estimate_hit(double);
protected:
        HMap flows;
};



In the .cc file:
#include <iostream>
#include <sstream>
#include <cmath>
#include <valarray>
#include <string>
#include <sys/types.h>
#include "config.h"
#include "template.h"
#include "flags.h"
#include "delay.h"
#include "rd.h"

using namespace std;

void Hash_Table::increment(int id, double t_now,
double ttl)
{
        HMap::iterator iter;
        iter=flows.find(id);
        double timelived, thresh;
        int hits;
 // bunch of stuff       
}

//other functions that I leave out.

Errors:
In file included from qd.cc:78:
qd.h:154: `hash' was not declared in this scope
qd.h:154: parse error before `>' token
qd.h:173: 'HMap' is used as a type, but is not defined
as a type.
qd.cc: In member function `void
Hash_Table::increment(int, double, double)':
qd.cc:1232: `HMap' undeclared (first use this
function)
qd.cc:1232: (Each undeclared identifier is reported
only once for each
   function it appears in.)
qd.cc:1232: parse error before `::' token
qd.cc:1233: `iter' undeclared (first use this
function)
qd.cc:1233: `flows' undeclared (first use this
function)
qd.cc: In member function `int
Hash_Table::findsize(double, bool)':
qd.cc:1274: parse error before `::' token
qd.cc: In member function `int Hash_Table::lookup(int,
double, double)':
qd.cc:1360: parse error before `::' token
make: *** [qd.o] Error 1

Similar errors for other functions removed for
simplicity.

Any help is appreciated.


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: compile errors
  2003-02-28 18:27 compile errors Guohua Ma
@ 2003-03-03 13:29 ` LLeweLLyn Reese
  0 siblings, 0 replies; 17+ messages in thread
From: LLeweLLyn Reese @ 2003-03-03 13:29 UTC (permalink / raw)
  To: Guohua Ma; +Cc: gcc-help

Guohua Ma <maguohua@hpc.me.utexas.edu> writes:

> dear sir:
>  I met some compiling problems when i use gcc3.2 to compile my program. my
> system is:
> redhat 8.0
> qt3-gcc3.2
> gcc 3.2
[snip]
> #ifndef PointerSwizzler_H
> #define PointerSwizzler_H
> 
> #include <typeinfo>
> #include <map>

using std::type_info;
using std::pair;
using std::map;

should fix most of your errors.

> 
> class PointerSwizzler {
> public:
>   PointerSwizzler() ;
>   ~PointerSwizzler() ;
> 
>   static unsigned long insert( void*, const type_info* ) ;
>   static unsigned long find( void*, const type_info* ) ;
>   static const type_info* find_type( void* ) ;
>   unsigned long operator() ( void*, const type_info* ) const ;
> 
>   static void reset() ;
> 
> protected:
>   typedef pair<void*,const type_info*> KeyType ;
> 
>   struct ltptr {
>     bool operator ()( KeyType a, KeyType b ) const
> {
> #if 0
>       return ( (a.first < b.first) ||
>                (a.first == b.first && a.second->before( *(b.second) ) ) )
> ;
> #else
>       return ( a.first < b.first ) ;
> #endif
>     }
>   } ;
> 
>   typedef pair< const pair<void*,const type_info*>, unsigned long>
> ValueType ;
>   typedef map< pair<void*,const type_info*>, unsigned long, ltptr >
> MapType ;
> 
> 
>   static MapType s_swizzler ;
>   static unsigned long s_current ;
> } ;
> 
> template<class T>
> unsigned long swizzle_pointer( T* pointer )
> {
>   const type_info* classid = &typeid( pointer ) ;
>   return PointerSwizzler::insert( reinterpret_cast<void*>(pointer),
> classid ) ;
> }
> 
> template<class T>
> unsigned long get_swizzle( T* pointer )
> {
>   const type_info* classid = &typeid( pointer ) ;
>   return PointerSwizzler::find( reinterpret_cast<void*>(pointer), classid
> ) ;
> }
> 
> inline const type_info* find_type( void* pointer )
> { return PointerSwizzler::find_type( pointer ) ; }
> 
> inline void reset_swizzler() { PointerSwizzler::reset() ; }
> 
> #endif // PointerSwizzler_H
> 
> 
> I searched through internet, however i couldnot fix it. could you help me
> to fix it?
> 
> guohua

^ permalink raw reply	[flat|nested] 17+ messages in thread

* compile errors
@ 2003-02-28 18:27 Guohua Ma
  2003-03-03 13:29 ` LLeweLLyn Reese
  0 siblings, 1 reply; 17+ messages in thread
From: Guohua Ma @ 2003-02-28 18:27 UTC (permalink / raw)
  To: gcc-help

dear sir:
 I met some compiling problems when i use gcc3.2 to compile my program. my
system is:
redhat 8.0
qt3-gcc3.2
gcc 3.2

can you help me to fix it? followings are error messages and source code.

error messages:

g++ -g -I.. -I/usr/lib/qt3-gcc3.2/include   -c -o PointerSwizzler.o
PointerSwizzler.C
In file included from PointerSwizzler.C:1:
../util/PointerSwizzler.H:12: parse error before `*' token
../util/PointerSwizzler.H:13: parse error before `*' token
../util/PointerSwizzler.H:14: ISO C++ forbids declaration of `type_info'
with
   no type
../util/PointerSwizzler.H:14: parse error before `*' token
../util/PointerSwizzler.H:15: parse error before `*' token
../util/PointerSwizzler.H:20: ISO C++ forbids declaration of `type name'
with
   no type
../util/PointerSwizzler.H:20: parse error before `*' token
../util/PointerSwizzler.H:23: `KeyType' was not declared in this scope
../util/PointerSwizzler.H:23: parse error before `,' token
../util/PointerSwizzler.H:34: ISO C++ forbids declaration of `type name'
with
   no type
../util/PointerSwizzler.H:34: parse error before `<' token
../util/PointerSwizzler.H:35: `pair' was not declared in this scope
../util/PointerSwizzler.H:35: parse error before `*' token
../util/PointerSwizzler.H:38: ISO C++ forbids declaration of `MapType'
with no
   type
../util/PointerSwizzler.H:38: parse error before `;' token
../util/PointerSwizzler.H: In member function `bool
   PointerSwizzler::ltptr::operator()(...) const':
../util/PointerSwizzler.H:29: `a' undeclared (first use this function)
../util/PointerSwizzler.H:29: (Each undeclared identifier is reported only
once
   for each function it appears in.)
../util/PointerSwizzler.H:29: `b' undeclared (first use this function)
../util/PointerSwizzler.H: In function `long unsigned int
swizzle_pointer(T*)':
../util/PointerSwizzler.H:45: ISO C++ forbids declaration of `type_info'
with
   no type
../util/PointerSwizzler.H:45: parse error before `*' token
../util/PointerSwizzler.H: In function `long unsigned int
get_swizzle(T*)':
../util/PointerSwizzler.H:52: ISO C++ forbids declaration of `type_info'
with
   no type
../util/PointerSwizzler.H:52: parse error before `*' token
../util/PointerSwizzler.H: At global scope:
../util/PointerSwizzler.H:56: syntax error before `*' token
PointerSwizzler.C:4: syntax error before `::' token
PointerSwizzler.C:16: parse error before `*' token
PointerSwizzler.C: In static member function `static long unsigned int
   PointerSwizzler::insert(...)':
PointerSwizzler.C:18: `KeyType' undeclared (first use this function)
PointerSwizzler.C:18: parse error before `(' token
PointerSwizzler.C:19: `MapType' undeclared (first use this function)
PointerSwizzler.C:20: `match' undeclared (first use this function)
PointerSwizzler.C:20: `key' undeclared (first use this function)
PointerSwizzler.C:23: `s_swizzler' undeclared (first use this function)
PointerSwizzler.C:23: `ValueType' undeclared (first use this function)
PointerSwizzler.C: At global scope:
PointerSwizzler.C:31: parse error before `*' token
PointerSwizzler.C: In member function `long unsigned int
   PointerSwizzler::operator()(...) const':
PointerSwizzler.C:33: parse error before `(' token
PointerSwizzler.C: At global scope:
PointerSwizzler.C:42: parse error before `*' token
PointerSwizzler.C: In static member function `static long unsigned int
   PointerSwizzler::find(...)':
PointerSwizzler.C:44: parse error before `(' token
PointerSwizzler.C: At global scope:
PointerSwizzler.C:52: syntax error before `*' token
PointerSwizzler.C:55: syntax error before `::' token
make: *** [PointerSwizzler.o] Error 1


my source code is:  //PointerSwizzler.H

#ifndef PointerSwizzler_H
#define PointerSwizzler_H

#include <typeinfo>
#include <map>

class PointerSwizzler {
public:
  PointerSwizzler() ;
  ~PointerSwizzler() ;

  static unsigned long insert( void*, const type_info* ) ;
  static unsigned long find( void*, const type_info* ) ;
  static const type_info* find_type( void* ) ;
  unsigned long operator() ( void*, const type_info* ) const ;

  static void reset() ;

protected:
  typedef pair<void*,const type_info*> KeyType ;

  struct ltptr {
    bool operator ()( KeyType a, KeyType b ) const
{
#if 0
      return ( (a.first < b.first) ||
               (a.first == b.first && a.second->before( *(b.second) ) ) )
;
#else
      return ( a.first < b.first ) ;
#endif
    }
  } ;

  typedef pair< const pair<void*,const type_info*>, unsigned long>
ValueType ;
  typedef map< pair<void*,const type_info*>, unsigned long, ltptr >
MapType ;


  static MapType s_swizzler ;
  static unsigned long s_current ;
} ;

template<class T>
unsigned long swizzle_pointer( T* pointer )
{
  const type_info* classid = &typeid( pointer ) ;
  return PointerSwizzler::insert( reinterpret_cast<void*>(pointer),
classid ) ;
}

template<class T>
unsigned long get_swizzle( T* pointer )
{
  const type_info* classid = &typeid( pointer ) ;
  return PointerSwizzler::find( reinterpret_cast<void*>(pointer), classid
) ;
}

inline const type_info* find_type( void* pointer )
{ return PointerSwizzler::find_type( pointer ) ; }

inline void reset_swizzler() { PointerSwizzler::reset() ; }

#endif // PointerSwizzler_H


I searched through internet, however i couldnot fix it. could you help me
to fix it?

guohua

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2005-03-29 17:13 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-29  0:06 Compile errors Parms singh
2005-03-29  6:23 ` corey taylor
2005-03-29 12:40 ` Eljay Love-Jensen
  -- strict thread matches above, loose matches on Subject: below --
2005-03-29 17:36 Parms singh
2005-03-28 22:55 Parms singh
2005-03-28 23:03 ` Eljay Love-Jensen
     [not found] <6667@adobe.com>
2005-03-28 22:13 ` Parms singh
2005-03-28 22:15   ` Eljay Love-Jensen
2005-03-28 22:51     ` corey taylor
2005-03-28 18:57 Parms singh
2005-03-28 19:55 ` corey taylor
2005-03-28 20:50   ` Parms singh
2005-03-28 22:01     ` corey taylor
2005-03-28 17:41 Parms singh
2005-03-28 18:00 ` corey taylor
2003-02-28 18:27 compile errors Guohua Ma
2003-03-03 13:29 ` LLeweLLyn Reese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).