diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-27 13:19:23 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-27 13:19:23 +0000 |
| commit | 27c0cafdfc66ce731156bf076644716f240318d4 (patch) | |
| tree | cefff28db49f48d12723fb30c41253096bf51ff1 /README.md | |
| parent | a3b85c9737b509fd2a792b65aa2365b9bcc9fe6a (diff) | |
Support for custom attributes
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -84,6 +84,8 @@ Join the discussion, share demos, ask questions, or report bugs in the official - [Plugins](#plugins) - [Generic C Macros](#generic-c-macros) - [13. Attributes](#13-attributes) + - [Custom Attributes](#custom-attributes) + - [Smart Derives](#smart-derives) - [14. Inline Assembly](#14-inline-assembly) - [Basic Usage](#basic-usage) - [Volatile](#volatile) @@ -873,6 +875,19 @@ Decorate functions and structs to modify compiler behavior. | `@host` | Fn | CUDA: Host function (`__host__`). | | `@comptime` | Fn | Helper function available for compile-time execution. | | `@derive(...)` | Struct | Auto-implement traits. Supports `Debug`, `Eq` (Smart Derive), `Copy`, `Clone`. | +| `@<custom>` | Any | Passes generic attributes to C (e.g. `@flatten`, `@alias("name")`). | + +### Custom Attributes + +Zen C supports a powerful **Custom Attribute** system that allows you to use any GCC/Clang `__attribute__` directly in your code. Any attribute that is not explicitly recognized by the Zen C compiler is treated as a generic attribute and passed through to the generated C code. + +This provides access to advanced compiler features, optimizations, and linker directives without needing explicit support in the language core. + +#### Syntax Mapping +Zen C attributes are mapped directly to C attributes: +- `@name` → `__attribute__((name))` +- `@name(args)` → `__attribute__((name(args)))` +- `@name("string")` → `__attribute__((name("string")))` ### Smart Derives |
