Created
April 7, 2018 21:50
-
-
Save M4GNV5/cb8184b0a89f782a6a2f3af1f409c3dd to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
printf "#include <stdio.h>\n" > /tmp/cppmacro.c | |
while [ $# -gt 1 ]; do | |
printf "#include <$1.h>\n" >> /tmp/cppmacro.c | |
shift | |
done | |
printf "int main()\n{\n\tprintf(\"%%d\\\\n\", $1);\n\treturn 0;\n}" >> /tmp/cppmacro.c | |
gcc -D_GNU_SOURCE /tmp/cppmacro.c -o /tmp/cppmacro | |
/tmp/cppmacro |
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
#!/bin/bash | |
printf "#include <stdio.h>\n#include <stddef.h>\n" > /tmp/structoffset.c | |
while [ $# -gt 2 ]; do | |
printf "#include <$1.h>\n" >> /tmp/structoffset.c | |
shift | |
done | |
printf "int main()\n{\n\tprintf(\"%%d\\\\n\", offsetof($1, $2));\n\treturn 0;\n}" >> /tmp/structoffset.c | |
gcc -D_GNU_SOURCE /tmp/structoffset.c -o /tmp/structoffset | |
/tmp/structoffset |
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
#!/bin/bash | |
printf "#include <stdio.h>\n" > /tmp/structsize.c | |
while [ $# -gt 1 ]; do | |
printf "#include <$1.h>\n" >> /tmp/structsize.c | |
shift | |
done | |
printf "int main()\n{\n\tprintf(\"%%d\\\\n\", sizeof($1));\n\treturn 0;\n}" >> /tmp/structsize.c | |
gcc -D_GNU_SOURCE /tmp/structsize.c -o /tmp/structsize | |
/tmp/structsize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment