Created
May 5, 2012 08:20
-
-
Save iwadon/2600879 to your computer and use it in GitHub Desktop.
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
| CC = gcc | |
| CC32 = gcc -m32 | |
| CC64 = gcc -m64 | |
| CFLAGS = -Wall -Wextra -g | |
| CPPFLAGS = | |
| LDFLAGS = | |
| LIBS = | |
| RM = rm -f | |
| TARGETS = sizeof sizeof32 sizeof64 | |
| all: $(TARGETS) | |
| clean: | |
| $(RM) $(TARGETS) | |
| sizeof: sizeof.c | |
| $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ sizeof.c | |
| sizeof32: sizeof.c | |
| $(CC32) $(CFLAGS) $(CPPFLAGS) -o $@ sizeof.c | |
| sizeof64: sizeof.c | |
| $(CC64) $(CFLAGS) $(CPPFLAGS) -o $@ sizeof.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 <inttypes.h> | |
| #include <limits.h> | |
| #include <stdio.h> | |
| int main(int argc, char *argv[]) | |
| { | |
| (void)argc; | |
| (void)argv; | |
| #ifdef __LP64__ | |
| #ifndef PRIuSIZE | |
| printf("PRIuSIZE not defined\n"); | |
| #define PRIuSIZE "lu" | |
| #endif | |
| printf("__LP64__ defined\n"); | |
| #else | |
| #ifndef PRIuSIZE | |
| printf("PRIuSIZE not defined\n"); | |
| #if defined(__APPLE__) | |
| #define PRIuSIZE "lu" | |
| #else | |
| #define PRIuSIZE "u" | |
| #endif | |
| #endif | |
| printf("__LP64__ not defined\n"); | |
| #endif | |
| #define PRINTF_SIZEOF(type) printf("sizeof (" #type ") = %" PRIuSIZE "\n", sizeof (type)) | |
| PRINTF_SIZEOF(int); | |
| PRINTF_SIZEOF(long); | |
| PRINTF_SIZEOF(int *); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment