mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00

This adds a new pragma for ImportC, which allows to set default storage classes. Only `nothrow`, `@nogc` and `pure` are supported for now. They can be disabled later using `#pragma attribute(pop)`. Unknown storage classes are ignored.
26 lines
922 B
Text
26 lines
922 B
Text
A pragma for ImportC allows to set `nothrow`, `@nogc` or `pure`
|
|
|
|
The following new pragma for ImportC allows to set default storage
|
|
classes for function declarations:
|
|
```
|
|
#pragma attribute(push, [storage classes...])
|
|
```
|
|
The storage classes `nothrow`, `nogc` and `pure` are supported.
|
|
Unrecognized attributes are ignored.
|
|
Enabling a default storage class affects all function declarations
|
|
after the pragma until it is disabled with another pragma.
|
|
Declarations in includes are also affected. The following example
|
|
enables `@nogc` and `nothrow` for a library:
|
|
|
|
```
|
|
#pragma attribute(push, nogc, nothrow)
|
|
#include <somelibrary.h>
|
|
```
|
|
|
|
The changed storage classes are pushed on a stack. The last change can
|
|
be undone with the following pragma:
|
|
```
|
|
#pragma attribute(pop)
|
|
```
|
|
This can also disable multiple default storage classes at the same time,
|
|
if they were enabled with a single `#pragma attribute(push, ...)` directive.
|