Next: , Previous: Freeing Obstack Objects, Up: Obstacks Obstack Functions and Macros

The interfaces for using obstacks are shown here as functions to specify the return type and argument types, but they are really defined as macros. This means that the arguments don't actually have types, but they generally behave as if they have the types shown. You can call these macros like functions, but you cannot use them in any other way (for example, you cannot take their address).

Calling the macros requires a special precaution: namely, the first operand (the obstack pointer) may not contain any side effects, because it may be computed more than once. For example, if you write this:

     obstack_alloc (get_obstack (), 4);

you will find that get_obstack may be called several times. If you use *obstack_list_ptr++ as the obstack pointer argument, you will get very strange results since the incrementation may occur several times.

If you use the GNU C compiler, this precaution is not necessary, because various language extensions in GNU C permit defining the macros so as to compute each argument only once.

Note that arguments other than the first will only be evaluated once, even when not using GNU C.

obstack.h does declare a number of functions, _obstack_begin, _obstack_begin_1, _obstack_newchunk, _obstack_free, and _obstack_memory_used. You should not call these directly.