delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/12/07/16:53:03

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <F10D23B02E54D011A0AB0020AF9CEFE999EE8C@lynx.ceddec.com>
From: "Town, Brad" <btown AT ceddec DOT com>
To: "Town, Brad" <btown AT ceddec DOT com>, "'Donald Brinkman'" <brinkman AT omi DOT com>,
"'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: RE: cv-quals lack an intervening 'const'
Date: Thu, 7 Dec 2000 16:52:42 -0500
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2653.19)

In fact, this sort of conversion is explicitly mentioned in the C++ standard
in section 4.4:

[Note: if a program could assign a pointer of type T** to a pointer of type
const T** (that is, if line //1 below was allowed), a program could
inadvertently modify a const object (as it is done on line //2).  For
example,

int main() {
	const char c = 'c';
	char* pc;
	const char** pcc = &pc;	//1: not allowed
	*pcc = &c;
	*pc = 'C';	//2: modifies a const object
}

-- end note]

Brad Town


> Donald,
> 	First, a cv-qualifier is a "const", "volatile", or 
> "const volatile"
> qualifier on a type.  (If you have access to the C++ standard, it's in
> section 3.9.3.)
> 	Second, your trouble is because gcc is being a little 
> more strict
> than the other compiler.  You need to add a "const" between 
> the two *'s in
> the return definition of the function.  Or, add "typedef 
> Foo** PPFoo" or the
> like and use that whenever you need to use the 
> pointer-to-pointer-to-Foo.
> 
> Brad Town
> 
> 
> > -----Original Message-----
> > From: Donald Brinkman [mailto:brinkman AT omi DOT com]
> > Sent: Thursday, December 7, 2000 4:21 PM
> > To: cygwin AT sourceware DOT cygnus DOT com
> > Subject: cv-quals lack an intervening 'const'
> > 
> > 
> > Hello all . . .
> > 
> > I have been given the task of porting a small project from an IRIX
> > environment into a visual c++ compatible library.  To 
> > accomplish this I
> > decided to use Cygwin, since it has such nice utilities for 
> > creating DLLs.
> > Everything has been going fine, with only a few changes here 
> > and there,
> > until I stopped dead on this problem.  Given the member function:
> > 
> > const Foo** FooBar::getA() const
> >         {
> >         return ( A )
> >         }
> > 
> > where A is a const Foo**
> > 
> > I get the following message:
> > 
> > Return to const Foo** from Foo **const adds cv-quals without 
> > intervening
> > 'const'.
> > 
> > 
> > Now, please, can someone tell me just what a cv-qual is and 
> > why the compiler 
> > complains about this on Cygwin with gcc but not on IRIX with 
> > cc? Any help
> > would be greatly appreciated.
> > 
> > Donald Brinkman
> > 
> > 
> > --
> > Want to unsubscribe from this list?
> > Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
> > 
> 
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
> 

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019