Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Meta tags (__FILE__, __LINE__, etc.)

Part of TutorialAdvanced

Description

These "special tokens" embedded helpful information into the program at compile time.

Example

/* Tested with DMD 0.118 */
/* Tested with DMD 1.0 */

import std.stdio;

int main (char[][] args)
{
    writef("Testing the D Code\n");
    writef("File:                %s\n",__FILE__);
    writef("Line:                %s\n",__LINE__);
    writef("Date:                %s\n",__DATE__);
    writef("Time:                %s\n",__TIME__);
    writef("TimeStamp:   %s\n",__TIMESTAMP__);

    return 0;
}

Source

Based on digitalmars.D:19553.