# dmd.globals

Stores command line options and contains other miscellaneous declarations.

#### Authors

Walter Bright

#### License

Boost License 1.0

Source: globals.d

Documentation: https://dlang.org/phobos/dmd_globals.html

Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/globals.d

- `DiagnosticReporting`

  #### Declaration

  `enum `DiagnosticReporting`: ubyte;`

  Defines a setting for how compiler warnings and deprecations are handled

  - `error`

    #### Declaration

    ``error``

    generate an `error`

  - `inform`

    #### Declaration

    ``inform``

    generate a warning

  - `off`

    #### Declaration

    ``off``

    disable diagnostic

- `MessageStyle`

  #### Declaration

  `enum `MessageStyle`: ubyte;`

  How code locations are formatted for diagnostic reporting

  - `digitalmars`

    #### Declaration

    ``digitalmars``

    filename.d(line): message

  - `gnu`

    #### Declaration

    ``gnu``

    filename.d:line: message, see https://www.gnu.org/prep/standards/html_node/Errors.html

- `CHECKENABLE`

  #### Declaration

  `enum `CHECKENABLE`: ubyte;`

  In which context checks for assertions, contracts, bounds checks etc. are enabled

  - `_default`

    #### Declaration

    ``_default``

    initial value

  - `off`

    #### Declaration

    ``off``

    never do checking

  - `on`

    #### Declaration

    ``on``

    always do checking

  - `safeonly`

    #### Declaration

    ``safeonly``

    do checking only in @safe functions

- `CHECKACTION`

  #### Declaration

  `enum `CHECKACTION`: ubyte;`

  What should happend when an assertion fails

  - `D`

    #### Declaration

    ``D``

    call `D` assert on failure

  - `C`

    #### Declaration

    ``C``

    call `C` assert on failure

  - `halt`

    #### Declaration

    ``halt``

    cause program `halt` on failure

  - `context`

    #### Declaration

    ``context``

    call D assert with the error `context` on failure

- `PIC`

  #### Declaration

  `enum `PIC`: ubyte;`

  Position Indepent Code setting

  - `fixed`

    #### Declaration

    ``fixed``

    located at a specific address

  - `pic`

    #### Declaration

    ``pic``

    Position Independent Code

  - `pie`

    #### Declaration

    ``pie``

    Position Independent Executable

- `JsonFieldFlags`

  #### Declaration

  `enum `JsonFieldFlags`: uint;`

  Each flag represents a field that can be included in the JSON output.

  NOTE: set type to uint so its size matches C++ unsigned type

- `CppStdRevision`

  #### Declaration

  `enum `CppStdRevision`: uint;`

  Version of C++ standard to support

- `CxxHeaderMode`

  #### Declaration

  `enum `CxxHeaderMode`: uint;`

  Configuration for the C++ header generator

  - `none`

    #### Declaration

    ``none``

    Don't generate headers

  - `silent`

    #### Declaration

    ``silent``

    Generate headers

  - `verbose`

    #### Declaration

    ``verbose``

    Generate headers and add comments for hidden declarations

- `FeatureState`

  #### Declaration

  `enum `FeatureState`: byte;`

  Trivalent boolean to represent the state of a `revert`able change

  - `default_`

    #### Declaration

    ``default_``

    Not specified by the user

  - `disabled`

    #### Declaration

    ``disabled``

    Specified as `-revert=`

  - `enabled`

    #### Declaration

    ``enabled``

    Specified as `-preview=`

- `Param`

  #### Declaration

  `struct `Param`;`

  Put command line switches in here

  - `ehnogc`

    #### Declaration

    `bool `ehnogc`;`

    The --transition=safe switch should only be used to show code with silent semantics changes related to @safe improvements. It should not be used to hide a feature that will have to go through deprecate-then-error before becoming default.

  - `doCxxHdrGeneration`

    #### Declaration

    `CxxHeaderMode `doCxxHdrGeneration`;`

    Generate 'Cxx header' file

- `Global`

  #### Declaration

  `struct `Global`;`

  Collection of global compiler settings and global state used by the frontend

  - `inifilename`

    #### Declaration

    `const(char)[] `inifilename`;`

    filename of configuration file as given by `-conf=`, or default value

  - `path`

    #### Declaration

    `Array!(const(char)*)* `path`;`

    Array of char*'s which form the import lookup `path`

  - `filePath`

    #### Declaration

    `Array!(const(char)*)* `filePath`;`

    Array of char*'s which form the file import lookup path

  - `vendor`

    #### Declaration

    `const(char)[] `vendor`;`

    Compiler backend name

  - `params`

    #### Declaration

    `Param `params`;`

    command line parameters

  - `errors`

    #### Declaration

    `uint `errors`;`

    number of `errors` reported so far

  - `warnings`

    #### Declaration

    `uint `warnings`;`

    number of `warnings` reported so far

  - `gag`

    #### Declaration

    `uint `gag`;`

    !=0 means `gag` reporting of errors & warnings

  - `gaggedErrors`

    #### Declaration

    `uint `gaggedErrors`;`

    number of errors reported while gagged

  - `gaggedWarnings`

    #### Declaration

    `uint `gaggedWarnings`;`

    number of warnings reported while gagged

  - `console`

    #### Declaration

    `void* `console`;`

    opaque pointer to `console` for controlling text attributes

  - `versionids`

    #### Declaration

    `Array!Identifier* `versionids`;`

    command line versions and predefined versions

  - `debugids`

    #### Declaration

    `Array!Identifier* `debugids`;`

    command line debug versions and predefined versions

  - `recursionLimit`

    #### Declaration

    `enum int `recursionLimit`;`

    number of recursive template expansions before abort

  - `startGagging`

    #### Declaration

    `nothrow uint `startGagging`();`

    Start ignoring compile errors instead of reporting them.

    #### Discussion

    Used for speculative compilation like `__traits(compiles, XXX)`, but also internally to e.g. try out an `alias this` rewrite without comitting to it.
    Works like a stack, so N calls to ``startGagging`` should be paired with N calls to `endGagging`.

    #### Return Value

    the current number of gagged errors, which should later be passed to `endGagging`

  - `endGagging`

    #### Declaration

    `nothrow bool `endGagging`(uint `oldGagged`);`

    Stop gagging, restoring the old gagged state before the most recent call to `startGagging`.

    #### Parameters

    `uint `oldGagged`` | the previous number of errors, as returned by `startGagging`

    #### Return Value

    `true` if errors occurred while gagged.

  - `increaseErrorCount`

    #### Declaration

    `nothrow void `increaseErrorCount`();`

    Increment the error count to record that an error has occurred in the current context.

    #### Discussion

    An error message may or may not have been printed.

  - `deinitialize`

    #### Declaration

    `nothrow void `deinitialize`();`

    Deinitializes the global state of the compiler.

    #### Discussion

    This can be used to restore the state set by `_init` to its original state.

  - `versionNumber`

    #### Declaration

    `nothrow uint `versionNumber`();`

    #### Return Value

    the version as the number that would be returned for __VERSION__

  - `versionString`

    #### Declaration

    `nothrow string `versionString`();`

    #### Return Value

    compiler version string.

  - `versionChars`

    #### Declaration

    `nothrow const(char*) `versionChars`();`

    #### Return Value

    compiler version as char string.

  - `finalDefaultlibname`

    #### Declaration

    `const nothrow const(char)[] `finalDefaultlibname`();`

    #### Return Value

    the final defaultlibname based on the command-line parameters

- `Loc`

  #### Declaration

  `struct `Loc`;`

  A source code location

  #### Discussion

  Used for error messages, `__FILE__` and `__LINE__` tokens, `__traits(getLocation, XXX)`, debug info etc.

  - `filename`

    #### Declaration

    `const(char)* `filename`;`

    zero-terminated `filename` string, either absolute or relative to cwd

  - `linnum`

    #### Declaration

    `uint `linnum`;`

    line number, starting from 1

  - `charnum`

    #### Declaration

    `uint `charnum`;`

    utf8 code unit index relative to start of line, starting from 1

  - `initial`

    #### Declaration

    `static immutable Loc `initial`;`

    use for default initialization of const ref Loc's

  - `equals`

    #### Declaration

    `const nothrow bool `equals`(ref const(Loc) `loc`);`

    Checks for equivalence by comparing the filename contents (not the pointer) and character location.

    Note:

    - Uses case-insensitive comparison on Windows
    - Ignores `charnum` if `global.params.showColumns` is `false`.
  - `opEquals`

    #### Declaration

    `const pure nothrow @nogc @trusted bool `opEquals`(ref const(Loc) `loc`);
    const pure nothrow @trusted size_t `toHash`();`

    ``opEquals`()` / ``toHash`()` for AA key usage

    #### Discussion

    Compare filename contents (case-sensitively on Windows too), not the pointer - a static foreach loop repeatedly mixing in a mixin may lead to multiple equivalent filenames (`foo.d-mixin-<line>`), e.g., for test/runnable/test18880.d.

  - `isValid`

    #### Declaration

    `const pure nothrow bool `isValid`();`

    #### Return Value

    `true` if Loc has been set to other than the default initialization

- `LINK`

  #### Declaration

  `enum `LINK`: ubyte;`

  A linkage attribute as defined by `extern(XXX)`

  #### Discussion

  https://dlang.org/spec/attribute.html#linkage

- `CPPMANGLE`

  #### Declaration

  `enum `CPPMANGLE`: ubyte;`

  Whether to mangle an external aggregate as a struct or class, as set by `extern(C++, struct)`

  - `def`

    #### Declaration

    ``def``

    default

  - `asStruct`

    #### Declaration

    ``asStruct``

    `extern(C++, struct)`

  - `asClass`

    #### Declaration

    ``asClass``

    `extern(C++, class)`

- `MATCH`

  #### Declaration

  `enum `MATCH`: int;`

  Function match levels

  #### Discussion

  https://dlang.org/spec/function.html#function-overloading

  - `nomatch`

    #### Declaration

    ``nomatch``

    no match

  - `convert`

    #### Declaration

    ``convert``

    match with conversions

  - `constant`

    #### Declaration

    ``constant``

    match with conversion to const

  - `exact`

    #### Declaration

    ``exact``

    `exact` match

- `PINLINE`

  #### Declaration

  `enum `PINLINE`: ubyte;`

  Inline setting as defined by `pragma(inline, XXX)`

  - `default_`

    #### Declaration

    ``default_``

    as specified on the command line

  - `never`

    #### Declaration

    ``never``

    `never` inline

  - `always`

    #### Declaration

    ``always``

    `always` inline

- `global`

  #### Declaration

  `Global `global`;`

  Collection of `global` state