New ask Hacker News story: Including Git commit-id as string inside C files

Including Git commit-id as string inside C files
2 by jagrsw | 0 comments on Hacker News.
Code: https://ift.tt/2wAnWnR Including contents of a text-file as a string in C is not that easy, esp. if it's not surrounded by quotes. One cannot simply write static const char str[] = #include "file" ; and static const char str[] = " #include "file" "; will not work either. If you know of a better (cleaner/shorter/less-hacky) way of doing this, and w/o external scripts/bins like `xxd -i` please let me know.

Comments