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

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Nov 6 21:28:04 PST 2007


"Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message 
news:fgqcai$2900$1 at digitalmars.com...

> 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*
>

I wouldn't necessarily trust the output of .stringof; it's known to be buggy 
in a lot of cases.  See if you can get the compiler to spit out an error 
containing the type, i.e.

void blah(T)()
{
    SOME_INVALID_FUNCTION();
}

...

blah!(PCHAR)();

This should make the compiler spit out some kind of error with the name of 
the instantiated blah, type included. 




More information about the Digitalmars-d-learn mailing list