Skip to content

Instantly share code, notes, and snippets.

@tidwall
Last active May 26, 2018 20:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tidwall/a38ccde24e0f4ae5f1a2a8a2ee4aba1d to your computer and use it in GitHub Desktop.
Save tidwall/a38ccde24e0f4ae5f1a2a8a2ee4aba1d to your computer and use it in GitHub Desktop.
Pass custom var strings to gcc
gcc -DgitSHA="$(git rev-parse HEAD)" main.c
#include <stdio.h>
#define STR1(x) #x
#define STR(x) STR1(x)
int main(){
printf("git: %s\n", STR(gitSHA));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment