# misc.h File Reference

This file contains some macros concerning lists and inheritance. More...

`#include <gwenhywfar/gwenhywfarapi.h>`
`#include <gwenhywfar/types.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <assert.h>`
`#include <gwenhywfar/memory.h>`

Go to the source code of this file.

## Defines

#define | GWEN_LIST_ADD(typ, sr, head)
#define | GWEN_LIST_DEL(typ, sr, head)
#define | GWEN_LIST_ELEMENT(t)
#define | GWEN_LIST_FINI(t, element)
#define | GWEN_LIST_FUNCTION_DEFS(t, pr) GWEN_LIST_FUNCTION_LIB_DEFS(t, pr, GWEN_DUMMY_EMPTY_ARG)
#define | GWEN_LIST_FUNCTION_LIB_DEFS(t, pr, decl)
#define | GWEN_LIST_FUNCTIONS(t, pr)
#define | GWEN_LIST_INIT(t, element) element->listPtr=0;
#define | GWEN_LIST_INSERT(typ, sr, head)

## Detailed Description

This file contains some macros concerning lists and inheritance.

FIRST: Yes, I DO know, macros are very, very bad. When writing these macros I spent much time debugging them, because the compiler is not much of a help here. The validity of a macro is only checked upon invocation, so if you never use a macro it will never be checked.

However, these macros do work just fine and they make some tasks much easier to handle.

The reason for using macros is the lack of templates in C. When writing Gwenhywfar I often faced the fact that some functions always appear with many structs defined. The only difference is the name of those functions and the type of the arguments.

The best example is the handling of lists of structs. In most listable structs there was a variable called next which pointed to the next object in the list. There were also functions like TYPE_next(), TYPE_add(), TYPE_del() etc for list handling. Whenever I improved the list mechanism I had to change ALL code files in order to improve them all.

These macros are now used to facilitate improvements in list or inheritance handling code in C.

NOTE: Please do not change these macros unless you know exactly what you are doing! Bugs in the macros will most probably lead to nearly undebuggable results in code files using them.
You have been warned ;-)