fam
[Top] [All Lists]

Re: [fam] GCC-3.1 compilation problems...

To: FAM <fam@xxxxxxxxxxx>
Subject: Re: [fam] GCC-3.1 compilation problems...
From: Christian Kreibich <kreibich@xxxxxxxxxxxxxxxxxxxxxxxxx>
Date: 29 May 2002 15:12:28 +0200
Organization:
Sender: owner-fam@xxxxxxxxxxx
Hi Michael,


On Wed, 2002-05-29 at 10:53, Michael Wardle wrote:
> Lars Pechan wrote:
>  > I'm trying to build fam-oss 2.6.7 using Gentoo Linux i386 with
>  > gcc3.1 and get the following output:
>  >
>  > c++ -DHAVE_CONFIG_H -I. -I. -I.. -I../include
>  > -DCONFIG_ETC_CONFIG_PATH=\"/etc/fam.conf\"    -Wno-deprecated -c
>  > Scheduler.c++
>  > Scheduler.c++:37: uninitialized const member
>  > `Scheduler::IOTypeInfo::iotype'
>  > Scheduler.c++:38: uninitialized const member
>  > `Scheduler::IOTypeInfo::iotype'
>  > make[2]: *** [Scheduler.o] Error 1
>  > make[2]: Leaving directory
>  > `/var/tmp/portage/fam-oss-2.6.7/work/fam-2.6.7/fam'
> 
> (Line numbers from FAM 2.6.7)
> 
> At line 107 of Scheduler.h, struct IOTypeInfo has a member iotype that
> is given a "const" modifier.  At line 123, two variables of type
> IOTypeInfo, "read" and "write" are declared.
> 
> As I'm more familiar with C than C++ (and I'm learning Java at the
> moment, so the exact terminologies and nuances of each is becoming a
> blur), there's a couple of things I'm trying to figure out...
> 
> 1. Is the position of the const modifier correct?  I'm accustomed to
>      seeing it before the type.  Is it possible to put the modifier
>      elsewhere in C++?

C++ knows the difference between a constant pointer (that cannot be made
pointing anywhere else) and a constant pointed-to object (whose contents
cannot be changed). In this case, it's a constant pointer.

The other confusing thing in the code involved are C++'s member
pointers. Bruce Eckel's Thinking In C++ has a lot of detail about the
various const flavours and member pointers.

> 2. Is the IOTypeInfo constructor called when "read" and "write" are
>      first declared at line 123?  If so, then this means they are
>      actually instantiated, not declared, correct?  If so, then
>      presumably calling the constructor at lines 37 and 38 of
>      Scheduler.c++ is trying to modify an already initialized const
>      member.  If so, how can this be overcome (other than removing the
>      const modifier, which seems to be a bad idea)?  If not, why
>      would the error be occurring at all?

Mhmmm the Scheduler's read and write IOTypeInfo members are static but
not const, so it should be okay to initialize them in Scheduler.c++ (and
not inside the header file), and the iotype member is a const member
pointer and gets initialized properly in the constructor's
initialization list of IOTypeInfo right at the start. I think everything
should be okay, the only thing that surprises me a bit is that you can
do

Scheduler::IOTypeInfo Scheduler::read(&FDInfo::read);
Scheduler::IOTypeInfo Scheduler::write(&FDInfo::write);

instead of 

Scheduler::IOTypeInfo Scheduler::read(&Scheduler::FDInfo::read);
Scheduler::IOTypeInfo Scheduler::write(&Scheduler::FDInfo::write);

But I doubt that this has any influence. Then again, my knowledge of C++
has become a bit rusty :)

Puzzled, 
Christian. 
-- 
________________________________________________________________________
                                                    http://www.whoop.org


--
Source code, list archive, and docs: http://oss.sgi.com/projects/fam/
To unsubscribe: echo unsubscribe fam | mail majordomo@xxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>