bug-cgicc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: cgicc compile on HP-UX 11.11 using aCC


From: JACQUOT,BRYAN (HP-FtCollins,ex1)
Subject: RE: cgicc compile on HP-UX 11.11 using aCC
Date: Mon, 14 Jan 2002 08:35:36 -0800

> -----Original Message-----
> From: Stephen F. Booth [mailto:address@hidden
> Sent: Sunday, January 13, 2002 12:35 PM
> 
> 
> > > > 2)  The MStreamable.cpp file is missing the 
> CGICC_BEGIN_NAMESPACE,
> > > >     and CGICC_END_NAMESPACE macros at the beginning and 
> end of the
> > > >     file.  I'm not sure why it compiles correctly with gcc, but
> the
> > > >     HP aCC compiler gave compiler errors without these macros.
> > > >
> > > >         Here's the (HP) diff -e output to fix the problem:
> > > >
> > > > BEGIN--------------------------------------------
> > > > 36a
> > > >
> > > > CGICC_END_NAMESPACE
> > > > .
> > > > 26a
> > > > CGICC_BEGIN_NAMESPACE
> > > >
> > > > .
> > > > END----------------------------------------------
> > >
> > > I'm not sure that MStreamable.cpp needs to have those macros-
> > > my general
> > > approach is that in longer cpp files I will use those 
> macros, but in
> > > shorter files like MStreamable I use the CGICCNS macro 
> which usually
> > > expands to 'cgicc::', which should take care of the scoping.  I'm
> not
> > > sure why it didn't work.  If you look at the 
> pre-processed output is
> > > there actually a namespace qualifier in front of the
> > > streaming operator?
> > 
> > Yes, here's (some of) the output from the preprocessor:
> > 
> > #line 30
> >  std:: ostream&
> >  cgicc:: operator<<( std:: ostream& out,
> >  const MStreamable& obj)
> > {
> >  obj.render(out);
> >  return out;
> > }
> > 
> > Here are the compile errors I get when I don't include those macros:
> > (The compiler can't find the def'n for the MStreamable class.)
> > And adding those name space macros fixes the problem.
> > I am not able to explain why.
> 
> I think I've made a mistake in the code-- shouldn't the implementation
> for operator<< look like
> 
> STDNS ostream&
> CGICCNS operator<<( STDNS ostream& out,
>       const CGICCNS MStreamable& obj)
> { ... }
> 
> ??
> 
> It looks like I left out the CGICCNS scoping for the 
> MStreamable object
> that is being written to the stream, which I guess is necessary.  Does
> this check with your understanding of C++ namespaces?  Even though
> operator<< is a member of the cgicc namespace, it doesn't 
> have access to
> all the members of that namespace until inside the function 
> definition.
> But I'm confused as to why it would work with gcc and others...
> 
> -Stephen


Ah ha, that make sense.  Because the CGICCNS scoping was omitted
for the MSTreabable parameter, the compiler was looking in the
global namespace.  Since the .h file declares MStreamable as part
of the CGICCNS, it appropriately couldn't find the object's
definition.  I don't know how gcc is finding the type of
MStreamable.

Bryan 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]