Derive-C
Loading...
Searching...
No Matches
def.h File Reference

Go to the source code of this file.

Macros

#define NAME   self_t
 Supporting templates that internally invoke new templates.
#define SELF   NAME
#define TEMPLATE_ERROR(...)
 With the user provided name, even in nested templates.

Macro Definition Documentation

◆ NAME

#define NAME   self_t

Supporting templates that internally invoke new templates.

Ideally we could do:

#define SELF foo
// within the template
#pragma push_macro("SELF")
#define SELF NS(SELF, internal_vector)
// ...
// ...
#pragma pop_macro("SELF")
// The rest of the structure definition ...

However, this is not possible, as macros are not eagrely expanded at definition

  • We cannot 'save' a macro, and redefine it in using its previous/saved value

To solve this, there are a few options

  1. For the user to provide names for internally used data structures
  2. A more complex scheme of stacking internal names (name 1, 2, etc)
  3. Namespace all macro paramaters (e.g. VECTOR_SELF, HASHMAP_SELF etc)

To keep code simple, but allow definitions to uniformly use SELF:

  • We restrict to 1 layer deep - NAME (from user), and INTERNAL_NAME (usage inside a template file, one layer deep).

Definition at line 51 of file def.h.

◆ SELF

#define SELF   NAME

Definition at line 52 of file def.h.

◆ TEMPLATE_ERROR

#define TEMPLATE_ERROR ( ...)
Value:
_Pragma(DC_STRINGIFY(GCC error DC_EXPAND_STRING(NAME) ": " __VA_ARGS__))
#define NAME
Supporting templates that internally invoke new templates.
Definition def.h:51
#define DC_STRINGIFY(MACRO)
Definition namespace.h:5
#define DC_EXPAND_STRING(NAME)
Definition namespace.h:6

With the user provided name, even in nested templates.

Definition at line 56 of file def.h.