www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - What is the difference between...

reply "Janice Caron" <caron serenityfirefly.com> writes:
What is the difference between:

 int f(const void * p, int len)

and

 int f(const(void)* p, int len)

?
Sep 07 2007
next sibling parent reply Xinok <xnknet gmail.com> writes:
const void*
This can also be read as:
const(void*)
This means that both 'void' and the pointer are const.

const(void)*
The pointer is mutable, but the data it points to must be const, even 
though it doesn't know the type of the data.

Janice Caron wrote:
 What is the difference between:
 
 int f(const void * p, int len)
 
 and
 
 int f(const(void)* p, int len)
 
 ?
 

Sep 07 2007
parent torhu <no spam.invalid> writes:
Xinok wrote:
 const void*
 This can also be read as:
 const(void*)
 This means that both 'void' and the pointer are const.

'const(void*)' is the same as 'const(void)*'. The reason is explained here: http://www.digitalmars.com/d/final-const-invariant.html Scroll down to "Invariant Doesn't Apply To Declared Symbols".
Sep 07 2007
prev sibling parent Derek Parnell <derek psych.ward> writes:
On Fri, 7 Sep 2007 10:54:25 +0100, Janice Caron wrote:

 What is the difference between:
 
  int f(const void * p, int len)

Can't change 'p'
 
  int f(const(void)* p, int len)

Can't change that which 'p' points to. (I think ...) -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Sep 07 2007