Created
May 23, 2017 14:48
-
-
Save brunoczim/2f293fd4dba2672b9a9b2fb7c39c726b to your computer and use it in GitHub Desktop.
Prints the size of a given C type in shell (requires gcc, but changes for whatever compiler you use are welcome).
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
#!/usr/bin/env sh | |
if [ $# -gt 0 ] | |
then | |
CODE="#include <stdio.h>"$'\n'"int main() { printf(\"%lu\n\", sizeof($@)); return 0; }" | |
echo "$CODE" | gcc -o size -x c - && ./size && rm -f size | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment