too much abstraction |
|
|
Posted by: stak Usually you can solve just about any problem by adding more layers of abstraction. Here's my recently-discovered exception to that rule:
#include <stdio.h> #include <setjmp.h> #define DOESNT_WORK int setjmpWrapper( void *jmpbuf ) { return setjmp( *(jmp_buf *)jmpbuf ); } void longjmpWrapper( void *jmpbuf, int retVal ) { longjmp( *(jmp_buf *)jmpbuf, retVal ); } int main( int argc, char ** argv ) { jmp_buf jmpBuffer; #ifdef DOESNT_WORK if (setjmpWrapper( &jmpBuffer )) { printf( "Success!\n" ); return 0; } longjmpWrapper( &jmpBuffer, 1 ); #else if (setjmp( jmpBuffer )) { printf( "Success!\n" ); return 0; } longjmp( jmpBuffer, 1 ); #endif return 1; }
|
(c) Kartikaya Gupta, 2004-2024. User comments owned by their respective posters. All rights reserved. You are accessing this website via IPv4. Consider upgrading to IPv6! |