Last active
May 26, 2018 20:04
-
-
Save tidwall/a38ccde24e0f4ae5f1a2a8a2ee4aba1d to your computer and use it in GitHub Desktop.
Pass custom var strings to gcc
This file contains hidden or 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
gcc -DgitSHA="$(git rev-parse HEAD)" main.c |
This file contains hidden or 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
#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