[Issue 24769] New: Add pragma compile on import

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 18 06:47:42 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24769

          Issue ID: 24769
           Summary: Add pragma compile on import
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: alphaglosined at gmail.com

Sometimes it is useful to have modules that are always compiled into each
binary that uses them.

These import-only modules should be able to be imported by setting the import
path, and the compiler will if it is used compile it in.

A pragma in the module can specify this behaviour ``pragma(compileonimport);``.

The existing solution for this is to use the ``-i`` switch.

This may be a useful addition wrt. the proposed phobos.sys.* package, that
could be import only.

The only catch is the object file will need to enable multiple definitions to
prevent linker errors.

--


More information about the Digitalmars-d-bugs mailing list