It's a pretty big hack and I'm not sure if it will work on anything but windows...
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
// Prototypes
void Function1( char* pszFmt, ... );
void Function2( char* pszFmt, ... );
// Calls Function2
void Function1( char* pszFmt, ... ) {
printf( "Log: %s\n", pszFmt );
Function2( pszFmt );
}
// Prints a message with numbers
__declspec( naked ) void Function2( char* pszFmt, ... ) {
static char szText[ 1024 ];
va_list argList;
va_start( argList, pszFmt );
_vsnprintf( szText, 1024, pszFmt, argList );
va_end( argList );
printf( szText );
// Since the __declspec( naked ) modifier doesn't generate
// any prolog or epilog code, we must return ourselves.
__asm ret;
}
int main( void ) {
Function1( "Its the numbers %d, %d, %d and %d!\n", 5, 3, 7, 9 );
return 0;
}