Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Well, I'm really no expert on define macros....(Yeah, I've no clue ^_^)
So, the obvious problem I can point out is that anything you send to a function, no matter what size it is, will ALWAYS be 32-bits on an x86 machine, meaning your VA_SIZE shouldn't return the size of something to add to the end of the stack, as it will vary from the 32 bits....instead, always add 4 bytes.
What exactly do you mean by "doesn't work"? It's not very helpful with programming problems when people just say "doesn't work"... Do you mean it doesn't compile? Outputs rubbish? Page faults?
In the former case, you have a 'pound' sign ("#") in front of your typedef, typedef is a C directive not a preprocessor directive. In the second case, I don't like those sorts of complex macros so I prefer the easy way out using the GCC builtin directives:
the output is rubbish.... a.expl. if i give to it a parameter 0x00 (32bit) the the content of the va_arg(_mode, int) is something like 0xXXXX00. but the code shouldn't be wrong...
gui/uiBitmap.c: In function `DrawBitmap':
gui/uiBitmap.c:38: error: incompatible type for argument 1 of `__builtin_va_start'
gui/uiBitmap.c:56: error: incompatible type for argument 1 of `__builtin_va_end'
gui/uiBitmap.c:43: error: first argument to `va_arg' not of type `va_list'
make.exe: *** [c] Error 1
Error open kernelc.bin
It should work on all GCC 3.x/4.x. If you want to support multiple compilers then I recommend using "#include <stdarg.h>" instead of defining your own macros.
Anon00000100 wrote:
As far as I can see, <stdarg.h> was what he was trying to implement in the first place...
I am suggesting to not implement a stdarg.h, just to use the one that came with the compiler (stdarg.h is part of the freestanding GCC environment [ie. it's a system header] and should be in other compilers as well).