supporting DMD-1.016 and DMD-2.000 with the same source code

torhu fake at address.dude
Sun Jul 1 05:43:46 PDT 2007


Thomas Kuehne wrote:
> 6) C-strings
> ============
> 
> Sometime I have to interface with C libries this "const char*" is
> required:
> 
> # static if(1 < dmd_version){
> #    mixin("alias const(char)* stringz;");
> # }else{
> #    alias char* stringz;
> # }
> 
> The mixin in required because the content has to be syntactically
> correct and "const(char)" isn't a valid DMD-1 construct.


Is there any reason not to use 'in' instead?  stringz looks a bit alien 
in C prototypes.

Phobos does just that, so I suppose it's okay:

char* strcpy(char* s1, in char* s2);



More information about the Digitalmars-d mailing list