The variable p and the variable's name "p" need to be passed to the macro
function to test for nullness and then to print some message involving the
variable's name.

Is there a crafty way of doing this so that only one thing needs to be
passed?

Thanks!





#include <stdlib.h>
#include <stdio.h>

#define CHECK_FOR_NULLITITY(var,varname) \
        if ( (var) == NULL ) \
        { \
                printf("%s is null.\n", varname); \
                exit(EXIT_FAILURE); \
        }



int main( void )
{
        char *p = NULL;
        CHECK_FOR_NULLITITY( p, "p" );

        return 0;
}
_______________________________________________
vox-tech mailing list
[email protected]
http://lists.lugod.org/mailman/listinfo/vox-tech

Reply via email to