Skip to content

Instantly share code, notes, and snippets.

@CyberShadow
Created September 8, 2011 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CyberShadow/1204546 to your computer and use it in GitHub Desktop.
Save CyberShadow/1204546 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
FILE *f;
char *cc, cmdline[1024];
if (argc != 3)
return fprintf(stderr, "Usage: %s header.h VALUE\n", argv[0]);
f = fopen("hvalue-test.c", "wt");
fprintf(f, "#include <%s>\n#include <stdio.h>\nvoid main()\n{ printf(\"%%d (0x%%x)\\n\", %s, %s); }\n", argv[1], argv[2], argv[2]);
fclose(f);
cc = getenv("CC");
if (!cc)
cc = "gcc";
sprintf(cmdline, "%s hvalue-test.c -o hvalue-test", cc);
if (system(cmdline))
return 1;
if (system("hvalue-test"))
return 1;
remove("hvalue-test.c");
remove("hvalue-test");
remove("hvalue-test.exe");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment