eĿlipsis
a language independent preprocessor
 
Loading...
Searching...
No Matches
ellipsis-predefined.dirs File Reference

Predefined macros for all languages. More...

Macros

#define    __UNIT__∷
 
#define    __PARENT_UNIT__∷
 
#define __COMPACT__(X, …)   __MAP__(__EVALUATE__, X)
 Expand all arguments and remove whitespace surrounding them.
 
#define __CONCAT__(…)
 evaluate and then concatenate up to 10 arguments
 
#define __EXPAND__(…)   __VA_ARGS__
 expand the arguments
 
#define __EXPAND_BIN__(…)   __EVALUATE_BIN__(__VA_ARGS__)
 expand all the arguments, evaluate the resulting integer expression and produce a binary literal
 
#define __EXPAND_BIN_U__(…)   __CONCAT__(__EXPAND_BIN__(__VA_ARGS__), U)
 expand all the arguments, evaluate the resulting integer expression and produce a binary literal
 
#define __EXPAND_COMMAS__(…)   __EXPAND_DEC__(__COMMAS__(__VA_ARGS__))
 expand all the arguments and count the number of toplevel commas in the resulting list
 
#define __EXPAND_DEC__(…)   __EVALUATE_DEC__(__VA_ARGS__)
 expand all the arguments, evaluate the resulting integer expression and produce a decimal literal
 
#define __EXPAND_DEC_U__(…)   __CONCAT__(__EXPAND_DEC__(__VA_ARGS__), U)
 expand all the arguments, evaluate the resulting integer expression and produce a decimal literal
 
#define __EXPAND_EMPTY__(…)   __EMPTY__(__VA_ARGS__)
 expand all the arguments and see if the result is empty
 
#define __EXPAND_ERROR__(...)   __ERROR__(__VA_ARGS__)
 Evaluate the __VA_ARGS__, use them as an error message and abord compilation.
 
#define __EXPAND_HEX__(…)   __EVALUATE_HEX__(__VA_ARGS__)
 expand all the arguments, evaluate the resulting integer expression and produce a hexadecimal literal
 
#define __EXPAND_HEX_U__(…)   __CONCAT__(__EXPAND_HEX__(__VA_ARGS__), U)
 expand all the arguments, evaluate the resulting integer expression and produce a hexadecimal literal
 
#define __EXPAND_OCT__(…)   __EVALUATE_OCT__(__VA_ARGS__)
 expand all the arguments, evaluate the resulting integer expression and produce a octal literal
 
#define __EXPAND_OCT_U__(…)   __CONCAT__(__EXPAND_OCT__(__VA_ARGS__), U)
 expand all the arguments, evaluate the resulting integer expression and produce a octal literal
 
#define __EXPAND_STRINGIFY__(…)   __STRINGIFY__(__VA_ARGS__)
 expand all the arguments and put the result into one string
 
#define __MAP__(F, …)   __FREEZE__(F)(__VA_ARGS__)__FREEZE__(__VA_OPT__)(, )__FREEZE__(__VA_TAIL__)()
 Construct the body of a macro mapping F over all variadic arguments.
 
#define __NARGS__(…)   __EXPAND_DEC__(__COMMAS__(__VA_ARGS__) + ¬__EMPTY__(__VA_ARGS__))
 expand all the arguments and count the number of items in the resulting list
 
#define __ONE__   __EXPAND_DEC__(1)
 A predefined and pre-evaluated 1
 
#define __PARENT_UNIT__
 A pseudo-macro that resolves to the name of the current parent unit.
 
#define __STDC_EMBED_EMPTY__   __EXPAND_DEC__(2)
 A predefined and pre-evaluated value as required by the C standard.
 
#define __STDC_EMBED_FOUND__   __EXPAND_DEC__(1)
 A predefined and pre-evaluated value as required by the C standard.
 
#define __STDC_EMBED_NOT_FOUND__   __EXPAND_DEC__(0)
 A predefined and pre-evaluated value as required by the C standard.
 
#define __STRINGIFY__(…)   ⌗__VA_ARGS__
 
#define __STRINGS__(X, …)   __MAP__(__STRINGIFY__, X)
 create a list of strings formed from all the arguments after they are expanded
 
#define __SUBUNIT__(NAME)
 A pseudo-macro that resolves to a name that is composed with the current parent unit name and NAME.
 
#define __UGLIFY__(X)   __ ⨝ X ⨝ __
 add two leading and trailing underscores to the identifier X
 
#define __UNIT__
 A pseudo-macro that resolves to the name associated with the current translation unit.
 
#define __UNLIST__(X, …)   X __VA_TAIL__()
 Expand all arguments and remove commas between them.
 
#define __VA_OPT__   __VA_OPT__
 A pseudo macro that cannot be redefined.
 
#define __VA_TAIL__   __VA_TAIL__
 A pseudo macro that cannot be redefined.
 
#define __ZERO__   __EXPAND_DEC__(0)
 A predefined and pre-evaluated 0
 
#define ELLIPSIS_LOOP_MAX   __EXPAND_DEC__((__ONE__ ◀ (ELLIPSIS_LOOP_WIDTH × ELLIPSIS_LOOP_DEPTH)) - __ONE__)
 The maximum number of iterations of the loop feature.
 
#define ELLIPSIS_LOOP_WIDTH   4
 The log₂ of the number of the per-level includes for the loop feature.
 

Detailed Description

Predefined macros for all languages.

Provide some convenient short cuts that tend otherwise to be redefined over and over again in user code.

Remarks
Because doxygen doesn't have it, yet, the documentation of these macros often uses #define where the macro is actually coded with #xdefine.
Warning
The macros in this group may not be undefined or redefined

Macro Definition Documentation

◆ [1/2]

#define ∷   __UNIT__∷

◆ [2/2]

#define ∷   __PARENT_UNIT__∷

◆ __COMPACT__

#define __COMPACT__ (   X,
  … 
)    __MAP__(__EVALUATE__, X)

Expand all arguments and remove whitespace surrounding them.

Warning
This macro may not be undefined or changed otherwise

◆ __CONCAT__

#define __CONCAT__ (   )

evaluate and then concatenate up to 10 arguments

Warning
If any argument consists of several tokens, its first token of is concatenated with the previous argument and its last token is concatenated with the next argument, if any. Using of this property is deprecated; use only with arguments that are single tokens.
This macro may not be undefined or changed otherwise

◆ __EXPAND__

#define __EXPAND__ (   )    __VA_ARGS__

expand the arguments

Warning
This macro may not be undefined or changed otherwise

◆ __EXPAND_BIN__

#define __EXPAND_BIN__ (   )    __EVALUATE_BIN__(__VA_ARGS__)

expand all the arguments, evaluate the resulting integer expression and produce a binary literal

Warning
This macro may not be undefined or changed otherwise

◆ __EXPAND_BIN_U__

#define __EXPAND_BIN_U__ (   )    __CONCAT__(__EXPAND_BIN__(__VA_ARGS__), U)

expand all the arguments, evaluate the resulting integer expression and produce a binary literal

The result is a binary integer literal with a U suffix such that it alwas is interpreted as unsigned number.

Warning
This macro may not be undefined or changed otherwise

◆ __EXPAND_COMMAS__

#define __EXPAND_COMMAS__ (   )    __EXPAND_DEC__(__COMMAS__(__VA_ARGS__))

expand all the arguments and count the number of toplevel commas in the resulting list

If there are no arguments, their expansion leads to nothing, or there are any but no toplevel comma, the result is 0.

Warning
This macro may not be undefined or changed otherwise

◆ __EXPAND_DEC__

#define __EXPAND_DEC__ (   )    __EVALUATE_DEC__(__VA_ARGS__)

expand all the arguments, evaluate the resulting integer expression and produce a decimal literal

The type of the constant is signed if it fits, otherwise unsigned.

Warning
This macro may not be undefined or changed otherwise

◆ __EXPAND_DEC_U__

#define __EXPAND_DEC_U__ (   )    __CONCAT__(__EXPAND_DEC__(__VA_ARGS__), U)

expand all the arguments, evaluate the resulting integer expression and produce a decimal literal

The result is a decimal integer literal with a U suffix such that it alwas is interpreted as unsigned number.

Warning
This macro may not be undefined or changed otherwise

◆ __EXPAND_EMPTY__

#define __EXPAND_EMPTY__ (   )    __EMPTY__(__VA_ARGS__)

expand all the arguments and see if the result is empty

Warning
This macro may not be undefined or changed otherwise

◆ __EXPAND_ERROR__

#define __EXPAND_ERROR__ (   ...)    __ERROR__(__VA_ARGS__)

Evaluate the __VA_ARGS__, use them as an error message and abord compilation.

Warning
This macro may not be undefined or changed otherwise

◆ __EXPAND_HEX__

#define __EXPAND_HEX__ (   )    __EVALUATE_HEX__(__VA_ARGS__)

expand all the arguments, evaluate the resulting integer expression and produce a hexadecimal literal

Warning
This macro may not be undefined or changed otherwise

◆ __EXPAND_HEX_U__

#define __EXPAND_HEX_U__ (   )    __CONCAT__(__EXPAND_HEX__(__VA_ARGS__), U)

expand all the arguments, evaluate the resulting integer expression and produce a hexadecimal literal

The result is a hexadecimal integer literal with a U suffix such that it alwas is interpreted as unsigned number.

Warning
This macro may not be undefined or changed otherwise

◆ __EXPAND_OCT__

#define __EXPAND_OCT__ (   )    __EVALUATE_OCT__(__VA_ARGS__)

expand all the arguments, evaluate the resulting integer expression and produce a octal literal

Warning
This macro may not be undefined or changed otherwise

◆ __EXPAND_OCT_U__

#define __EXPAND_OCT_U__ (   )    __CONCAT__(__EXPAND_OCT__(__VA_ARGS__), U)

expand all the arguments, evaluate the resulting integer expression and produce a octal literal

The result is a octal integer literal with a U suffix such that it alwas is interpreted as unsigned number.

Warning
This macro may not be undefined or changed otherwise

◆ __EXPAND_STRINGIFY__

#define __EXPAND_STRINGIFY__ (   )    __STRINGIFY__(__VA_ARGS__)

expand all the arguments and put the result into one string

Warning
This macro may not be undefined or changed otherwise

◆ __MAP__

#define __MAP__ (   F,
  … 
)    __FREEZE__(F)(__VA_ARGS__)__FREEZE__(__VA_OPT__)(, )__FREEZE__(__VA_TAIL__)()

Construct the body of a macro mapping F over all variadic arguments.

This can be used in combination with #xdefine to declare a functional macro that maps F over all its other arguments, as in

#xdefine __STRINGS__(X, ...) __MAP__(__STRINGIFY__, X)

If the macro F receives more than one argument list them all in the call to __MAP__.

#xdefine TWO_STRINGS(X, Y, ...) __MAP__(__STRINGIFY__, X, Y)

◆ __NARGS__

#define __NARGS__ (   )    __EXPAND_DEC__(__COMMAS__(__VA_ARGS__) + ¬__EMPTY__(__VA_ARGS__))

expand all the arguments and count the number of items in the resulting list

If there are no arguments or their expansion leads to nothing, the result is 0. Otherwise the result is the number of toplevel commas in the expansion plus one.

Warning
This macro may not be undefined or changed otherwise

◆ __ONE__

#define __ONE__   __EXPAND_DEC__(1)

A predefined and pre-evaluated 1

Warning
This macro may not be undefined or changed otherwise

◆ __PARENT_UNIT__

#define __PARENT_UNIT__

A pseudo-macro that resolves to the name of the current parent unit.

For a top-level C file the parent would be the project name, if that is set from __PROJECT__, for files that are deeper in the include hierarchy, other subunit names may already have been added to that.

See also
Preprocessor state and identifier composition
__UNIT__
__SUBUNIT__
__PROJECT__

◆ __STDC_EMBED_EMPTY__

#define __STDC_EMBED_EMPTY__   __EXPAND_DEC__(2)

A predefined and pre-evaluated value as required by the C standard.

Warning
This macro may not be undefined or changed otherwise

◆ __STDC_EMBED_FOUND__

#define __STDC_EMBED_FOUND__   __EXPAND_DEC__(1)

A predefined and pre-evaluated value as required by the C standard.

Warning
This macro may not be undefined or changed otherwise

◆ __STDC_EMBED_NOT_FOUND__

#define __STDC_EMBED_NOT_FOUND__   __EXPAND_DEC__(0)

A predefined and pre-evaluated value as required by the C standard.

Warning
This macro may not be undefined or changed otherwise

◆ __STRINGIFY__

#define __STRINGIFY__ (   )    ⌗__VA_ARGS__

◆ __STRINGS__

#define __STRINGS__ (   X,
  … 
)    __MAP__(__STRINGIFY__, X)

create a list of strings formed from all the arguments after they are expanded

Warning
This macro may not be undefined or changed otherwise

◆ __SUBUNIT__

#define __SUBUNIT__ (   NAME)

A pseudo-macro that resolves to a name that is composed with the current parent unit name and NAME.

For a top-level C file the parent would be the project name, for files that are deeper in the include hierarchy, other subunit names may already have been added to that.

See also
Preprocessor state and identifier composition
__UNIT__
__PARENT_UNIT__
__PROJECT__

◆ __UGLIFY__

#define __UGLIFY__ (   X)    __ ⨝ X ⨝ __

add two leading and trailing underscores to the identifier X

Warning
This macro may not be undefined or changed otherwise

◆ __UNIT__

#define __UNIT__

A pseudo-macro that resolves to the name associated with the current translation unit.

This is not set automatically, so if you want to use this feature you'd have to set this manually. Usually this would be done at the start of the translation unit. For a .c file this would typically look like

#xbind __UNIT__ hurli∷purtz

for an absolute (unrelated) name or

#xbind __SUBUNIT__(macros)

for a name that is prefixed with the current project name.

In all cases the translation unit may then be abbreviated with .∷ as in

void .∷hello(void);

If the name is defined with the __SUBUNIT__ feature, another shortcut ..∷ refers to the parent unit.

Note the use of #xbind (or #expand bind if you prefer): it is important that the whole line is expanded and that the definition is restricted to the current source file.

In a header file, that is generally included into completely unrelated code, you should prefer the first form, such that the contents of the header expands to the same, regardless of the context.

When ellipsis is used as a first phase preprocessor such names are all expanded into long forms that are usually separated by a character (UNDERTIE, U203F). For example if the project is magn∷ificient with the above subunit __UNIT__ would expand to magn‿ificient‿macros and the function name would be magn‿ificient‿macros‿hello.

See also
Preprocessor state and identifier composition
__PARENT_UNIT__
__PROJECT__

◆ __UNLIST__

#define __UNLIST__ (   X,
  … 
)    X __VA_TAIL__()

Expand all arguments and remove commas between them.

Warning
This macro may not be undefined or changed otherwise

◆ __VA_OPT__

#define __VA_OPT__   __VA_OPT__

A pseudo macro that cannot be redefined.

The __VA_OPT__ construct is only active in the replacement list of a variadic macro and must be present at the point of definition. Any other occurence triggers this macro here and passes the token through.

Warning
This macro may not be undefined or changed otherwise

◆ __VA_TAIL__

#define __VA_TAIL__   __VA_TAIL__

A pseudo macro that cannot be redefined.

The __VA_TAIL__ construct is only active in the replacement list of a variadic macro at the very end of expansion. Any other occurence triggers this macro here and passes the token through.

See also
Tail recursion
Warning
This macro may not be undefined or changed otherwise

◆ __ZERO__

#define __ZERO__   __EXPAND_DEC__(0)

A predefined and pre-evaluated 0

Warning
This macro may not be undefined or changed otherwise

◆ ELLIPSIS_LOOP_MAX

The maximum number of iterations of the loop feature.

See also
ellipsis-loop.dirs
Warning
This macro may not be undefined or changed otherwise

◆ ELLIPSIS_LOOP_WIDTH

#define ELLIPSIS_LOOP_WIDTH   4

The log₂ of the number of the per-level includes for the loop feature.

See also
ellipsis-loop.dirs
Warning
This macro may not be undefined or changed otherwise