|
CX Framework
Cross-platform C utility framework
|
Macros | |
| #define | inhibitDeclare(name) enum { _inhibit_name(name) = 0 } |
| #define | inhibitCheck(name) switch(tokstring(_inhibit_name(name))[_inhibit_name(name)]) default: |
| #define | inhibitDisallow(name) _blkStart _inhibitDisallow(name) |
| #define | inhibitAllow(name) _blkStart _inhibitAllow(name) |
Compile-time checks to prevent use of specific language features within certain blocks.
This facility allows library code to enforce correct usage patterns by disallowing certain operations (like return) within blocks where they would cause problems such as resource leaks or incorrect control flow.
In debug builds, attempting to use an inhibited feature results in a compile error. In release builds, the checks are disabled for performance.
| #define inhibitAllow | ( | name | ) | _blkStart _inhibitAllow(name) |
Allows the use of a previously inhibited feature inside the given block.
This creates an exception to an outer inhibitDisallow() block, permitting the feature to be used within this nested scope.
| name | Feature identifier to allow |
| #define inhibitCheck | ( | name | ) | switch(tokstring(_inhibit_name(name))[_inhibit_name(name)]) default: |
Results in a compile error if the specified feature is inhibited in the current block.
This is typically used by redefining language keywords to check themselves. For example, the return keyword is redefined in debug builds to check if RETURN is inhibited.
| name | Feature identifier to check |
| #define inhibitDeclare | ( | name | ) | enum { _inhibit_name(name) = 0 } |
Declares a feature that can be inhibited at compile time.
| name | Feature identifier to declare |
| #define inhibitDisallow | ( | name | ) | _blkStart _inhibitDisallow(name) |
Inhibits the use of a feature inside the given block.
Any attempt to use the inhibited feature within the block will result in a compile error in debug builds. This is typically used by library code to prevent incorrect usage patterns.
| name | Feature identifier to inhibit |
Example: