Guideline for D1/2 compatible code?
Trass3r
mrmocool at gmx.de
Sun Jan 18 05:59:35 PST 2009
Am 17.01.2009, 23:19 Uhr, schrieb Stewart Gordon <smjg_1998 at yahoo.com>:
> Trass3r wrote:
>> Are there any guidelines for writing code compilable with both dmd 1.x
>> and 2.x?
>
> This is to make a library usable by users of either, I presume?
>
Yes.
> - Have a module to define types for such things as pointers/arrays that
> will be const in D2.
>
Yeah, using the following atm:
alias char[] string;
alias const(char)[] cstring;
alias invariant(char)[] istring;
> - Use version(D_Version2) for bits of code that need to be different
> between the two.
>
> - Use string mixins to include D2 code that is syntactically illegal
> under D1.
>
I'd like to use "alias char[] string", but dmd complains about conflicts
with the builtin "alias invariant(char)[] string"
Is there any way to redefine string in the scope of the library?
I know I could simply use another name or use char[] but if it's possible
to redefine it, I'd love to do that.
More information about the Digitalmars-d-learn
mailing list