On Wed, 2004-08-25 at 07:52, Kevin Glynn wrote: > Daniel Kobras writes: > > On Tue, Aug 24, 2004 at 06:21:57PM +0200, Kevin Glynn wrote: > > > fyi, it is because va_list is declared as a one-element array of > > > structs on powerpc, unlike other architectures so code like: > > > > > > va_list Arg4 = (va_list) OZ_getForeignPointer((*(_OZ_LOC[(4)]))); > > > > > > fails on powerpc, because you can't cast to an array. > > > > And you may not assign to a va_list. Use va_copy() instead to be > > portable. > > > > Daniel. > > > > I don't see how va_copy will help me. OZ_getForeignPointer(...) > returns a void*, so I will still need to cast it to a va_list to be > able to call va_copy. Here is my test program, perhaps you can suggest > an alternative:
Due to some disgusting changes in the C standard, casting from (void*) is pretty much illegal anyway. I expect that C++ is affected as well. It has to do with pointer aliasing. Use a union. Put all the types you need into the union. So you'd use a pointer to a union, and skip the casting. Use the -Wstrict-aliasing=2 compiler option. I use: -W -Wall -Wshadow -Wcast-align -Wredundant-decls \ -Wbad-function-cast -Wcast-qual -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wmissing-prototypes \ -Wdeclaration-after-statement -Wpadded -Wstrict-aliasing=2 (those last 3 depending on a recent gcc)