compile time output

Bill Baxter wbaxter at gmail.com
Tue Jan 20 08:19:11 PST 2009


On Wed, Jan 21, 2009 at 12:36 AM, Trass3r <mrmocool at gmx.de> wrote:
> Is there any way to output information at compile time other than
> pragma(msg?
> pragma is driving me crazy, the following doesn't work:
>
> auto members = __traits(allMembers, typeof(this));
> foreach(m; members)
> {
>        pragma(msg, m);
> }
>
> -> Error: string expected for message, not 'm'
>
> Though the docs clearly state:
> allMembers: "An array of string literals is returned"
> Also checked that, m is of type invariant(char)[].
>
>
> Any ideas? -.-

try indexing explicitly or using ref:

foreach(i,m; members)
{
    pragma(msg, members[i]);
}

foreach(ref m; members)
{
    pragma(msg, m);
}

Latter one may not be useful.  I can't recall.
--bb


More information about the Digitalmars-d-learn mailing list