www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14681] New: Add a way to specify a file import's contents on


          Issue ID: 14681
           Summary: Add a way to specify a file import's contents on the
                    command line
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: yebblies gmail.com

C/C++ compilers generally have the ability to set preprocessor symbols from the
command line.  While dmd's -version=ident covers most use cases, it is
sometimes useful to set the symbol to a specific value and access this inside
the program.


With DMD this can be done by creating a file and using -J/import(), but there
is no way to set the value directly on the command line.

My proposed syntax to extend -J/import() to allow setting a value:
dmd -J:key=value main.d

Then in the program the import() syntax is used to retrieve the value:
static assert(import(":key") == "value");

The ':' prefix allows the compiler to tell apart import paths and key/value

Jun 10 2015