how do I make an alias for a const version of an alias in D 2.0?

Steven Schveighoffer schveiguy at yahoo.com
Tue Nov 6 10:38:09 PST 2007


I have an issue where I have a custom pointer type like so:

alias char * PCHAR;

I want a const version of this, but if I do this:

alias const(PCHAR) C_PCHAR;

C_PCHAR is still char *

here is some demonstrating code:

alias char * PCHAR;
alias const(PCHAR) C_PCHAR;
alias const(char *) C_PCHAR2;


void main()
{
  pragma(msg, (const(PCHAR)).stringof);
  pragma(msg, C_PCHAR.stringof);
  pragma(msg, C_PCHAR2.stringof);
}

compiling this outputs:
const char*
char*
const char*

Note that using const(PCHAR) in the code and not in the alias results in the 
correct behavior

Is this a bug?  I'm using D 2.007.

-Steve 




More information about the Digitalmars-d-learn mailing list