Created
October 12, 2012 10:24
-
-
Save anonymous/3878585 to your computer and use it in GitHub Desktop.
stdin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void *av_x_if_null(const void *x, const void *y) | |
{ | |
return (void *) (x ? x : y); | |
} | |
#define WARN_IF_TYPES_DIFFER(x,y) ((void) sizeof(x == y)) | |
#define av_x_if_null_warn(x,y) \ | |
( \ | |
WARN_IF_TYPES_DIFFER(x, y), \ | |
av_x_if_null(x, y) \ | |
) | |
int main(void) | |
{ | |
int *a = 0; | |
char *b = 0; | |
int *i = av_x_if_null_warn(a, a); // fine | |
short *c = av_x_if_null_warn(i, b); | |
return c ? 1 : 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment