7 Versionstring: $VER: SDI_stdarg.h 1.1 (06.06.2014)
10 Project page: http://sf.net/p/adtools/code/HEAD/tree/trunk/sdi/
11 Description: defines to hide OS specific variable arguments
14 URL: $URL: svn://svn.code.sf.net/p/adtools/code/trunk/sdi/SDI_stdarg.h $
16 1.0 05.07.2004 : initial version
17 1.1 06.06.2014 : added a type cast to VA_ARG() result
22 ** This is PD (Public Domain). This means you can do with it whatever you want
23 ** without any restrictions. I only ask you to tell me improvements, so I may
24 ** fix the main line of this files as well.
26 ** To keep confusion level low: When changing this file, please note it in
27 ** above history list and indicate that the change was not made by myself
28 ** (e.g. add your name or nick name).
30 ** Find the latest version of this file at:
31 ** http://sf.net/p/adtools/code/HEAD/tree/trunk/sdi/
33 ** Jens Maus <mail@jens-maus.de>
34 ** Dirk Stöcker <soft@dstoecker.de>
37 #include "SDI_compiler.h"
40 ** Variable arguments function macros to allow specification of the
41 ** variable arguments typical functions like va_list/va_start/va_end in
42 ** an operating system independent fashion.
44 ** With help of the following macro definition a developer might define
45 ** variable arguments functions for different types of operating
46 ** system implementations without having to clutter the sources with
47 ** multiple "#ifdef" defines just because all of these operating systems
48 ** come with different varable arguments support functions.
52 ** Instead of using the standard va_list, va_start and va_end functions
53 ** of <stdarg.h>, a developer might specify the following sprintf()
54 ** function to make it automatically compatible with AmigaOS3, AmigaOS4
57 ** int VARARGS68K sprintf(char *buf, char *fmt, ...)
61 ** VA_START(args, fmt);
62 ** RawDoFmt(fmt, VA_ARG(args, void *), NULL, buf);
65 ** return(strlen(buf));
68 ** Please note the uppercase letters of the macros in contrast to the
69 ** official varargs functions specified in <stdarg.h>.
71 ** By using this schema a developer might ensure full source code backward
72 ** compatibility to AmigaOS3 without having to introduce dozens of #ifdef
73 ** statements in his code.
91 #if defined(__amigaos4__)
92 #define VA_LIST va_list
93 #define VA_START(va, start) va_startlinear((va), (start))
94 #define VA_ARG(va, type) va_getlinearva((va), type)
95 #define VA_END(va) va_end((va))
96 #elif defined(__MORPHOS__)
97 #define VA_LIST va_list
98 #define VA_START(va, start) va_start((va), (start))
99 #define VA_ARG(va, type) (type)((va)->overflow_arg_area)
100 #define VA_END(va) va_end((va))
102 #define VA_LIST va_list
103 #define VA_START(va, start) va_start((va), (start))
104 #define VA_ARG(va, type) (type)(va)
105 #define VA_END(va) va_end((va))
108 #endif /* SDI_STDARG_H */