I am in the process of writing a non-destructive conversion routine in C and I have just realized that (at least in Visual C++) functions are resolved in the reverse order.
So:
main()
{
char* psString[] = { "Hello", "World", "World2", "World3" };
printf("%s - %s - %s - %s\n",
H2A_N(psString[0]),
H2A_N(psString[1]),
H2A_N(psString[2]),
H2A_0(psString[3]));
return 1;
};
My code is not re-entrant and runs only in a single thread so I was going to use a static array of characters to store the results.
My plan was to have a function H2A_0 which wrote the output to the start of the buffer and left behind the next address for subsequent calls to H2A_N.
I do realize there are some shortcomings to this approach but I have to apply this conversion routine to a lot of existing code so the simpler the better (I don't want to mess with releasing memory).
My question is:
- Is it part of the C standard to resolve functions (when they are passed as arguments to other functions) in reverse order.
- Is there a better way to do this?