file
Def.hDef provides various #define
s for performing basic tasks and macro-related functions.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Defines
- #define CNX_DEF
- definitions related to Standard Defines
- #define CNX_VERSION_MAJOR
- The major portion of the version number of the Cnx library e.g. in "x.y.z", the "x" part.
- #define CNX_VERSION_MINOR
- The minor portion of the version number of the Cnx library e.g. in "x.y.z", the "y" part.
- #define CNX_VERSION_PATCH
- The patch portion of the version number of the Cnx library e.g. in "x.y.z", the "z" part.
- #define CNX_VERSION
- The version number of the Cnx library parsed into a single 32-bit integer Each portion of the version number will take 8 bits in the resulting integer, with the total parsed version number comprising of the lower 24 bits. The layout is
00000000xxxxxxxxyyyyyyyyzzzzzzzz
where: - #define UNIQUE_VAR(x)
- Provides a semi-unique variable name with
x
as a prefix. - #define typeof(value)
- Returns the type of the given expression.
- #define alignof(type)
- Returns the alignment size in bytes of the given type.
- #define cnx_disable(message)
- Disables the preceding/following function at compile-time.
- #define cnx_disable_if(condition, message)
- Disables the preceding/following function at compile-time, based on the given
condition
- #define cnx_enable_if(condition, message)
- Enables the preceding/following function at compile-time, based on the given
condition
- #define cnx_warn_if(condition, message)
- Emits a warning for using the preceding/following function at compile-time, based on the given
condition
- #define unreachable()
- Specify that the given scope is unreachable.
- #define always_inline
- Specify that the following function should always be inlined.
- #define not_null(...)
- Attribute to specify that the function arguments in the indicated positions (1-based indices) should not be nullptr.
- #define returns_not_null
- Attribute to specify that the pointer the function returns will never be nullptr.
- #define nodiscard
- Attribute to specify that the return value of the tagged function should not be discarded.
- #define maybe_unused
- Attribute to specify that a value may be unused or discarded.
- #define scoped(scope_end_func)
- Use this macro to declare a variable that will have a cleanup function called on it at scope end.
- #define move(self)
- Moves
self
into the assigned-to or bound-to variable/parameter/etc. - #define let
- Declare a variable with
let
to create aconst
variable with inferred type. - #define let_mut
- Declare a variable with
let_mut
to create a mutable variable with inferred type. - #define loop
- Use to declare an infinite loop, equivalent to
while(true)
orfor(;;)
- #define Ptr(T)
- shorthand for writing
T_ptr
, used for generating typedef names needed for macros that require an alphanumeric name forT*
- #define Ref(T)
- shorthand for writing
T_ptr
, used for generating typedef names needed for macros that require an alphanumeric name forT*
when implying reference-like semantics - #define ConstRef(T)
- shorthand for writing
const_T_ptr
, used for generating typedef names needed for macros that require an alphanumeric name forconst T*
when implying reference-like semantics - #define ranged_for(var, begin, end)
- Shorthand for writing a
for
loop. - #define ignore(...)
- Ignores the given parameters.
- #define static_cast(Type)
- Casts to the type
Type
. - #define narrow_cast(Type)
- Casts to the type
Type
. - #define const_cast(Type)
- Casts to the type
Type
. - #define false
- Define the boolean constant
false
- #define true
- Define the boolean constant
true
- #define CONCAT(...)
- Concatenates an arbitrary number of arguments.
- #define CONCAT_DEFERRED(...)
- Concatenates an arbitrary number of arguments, with one additional layer of indirection.
- #define BEGIN_SCOPED_VARIABLES()
- Creates a scope for wrapping an arbitrary number of variable declarations in with subsequent uses of
SCOPE_
. The net scope will make up one single compound-statement.VARIABLE() - #define SCOPE_VARIABLE(...)
- Wraps the given variable declaration(s) in a containing scope. The scope must have been previously initiated with
BEGIN_
. Variable declarations must be compatible with the initialization statement (aka the "clause" statement) in a for loop. The net scope will make one a single compound-statement.SCOPED_ VARIABLES()