macos: tcc searches for libtcc.dyln in the same directory as its executable
[tinycc.git] / conftest.c
blobf3b6ea6561df8268024218a310b4b6e6a95e10d8
1 #include <stdio.h>
3 #if defined(_WIN32)
4 #include <fcntl.h>
5 #endif
7 /* Define architecture */
8 #if defined(__i386__) || defined _M_IX86
9 # define TRIPLET_ARCH "i386"
10 #elif defined(__x86_64__) || defined _M_AMD64
11 # define TRIPLET_ARCH "x86_64"
12 #elif defined(__arm__)
13 # define TRIPLET_ARCH "arm"
14 #elif defined(__aarch64__)
15 # define TRIPLET_ARCH "aarch64"
16 #elif defined(__riscv) && defined(__LP64__)
17 # define TRIPLET_ARCH "riscv64"
18 #else
19 # define TRIPLET_ARCH "unknown"
20 #endif
22 /* Define OS */
23 #if defined (__linux__)
24 # define TRIPLET_OS "linux"
25 #elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
26 # define TRIPLET_OS "kfreebsd"
27 #elif defined(_WIN32)
28 # define TRIPLET_OS "win32"
29 #elif defined(__APPLE__)
30 # define TRIPLET_OS "darwin"
31 #elif !defined (__GNU__)
32 # define TRIPLET_OS "unknown"
33 #endif
35 /* Define calling convention and ABI */
36 #if defined (__ARM_EABI__)
37 # if defined (__ARM_PCS_VFP)
38 # define TRIPLET_ABI "gnueabihf"
39 # else
40 # define TRIPLET_ABI "gnueabi"
41 # endif
42 #else
43 # define TRIPLET_ABI "gnu"
44 #endif
46 #if defined _WIN32
47 # define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS
48 #elif defined __GNU__
49 # define TRIPLET TRIPLET_ARCH "-" TRIPLET_ABI
50 #else
51 # define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS "-" TRIPLET_ABI
52 #endif
54 #if defined(_WIN32)
55 int _CRT_glob = 0;
56 #endif
58 int main(int argc, char *argv[])
60 #if defined(_WIN32)
61 _setmode(_fileno(stdout), _O_BINARY); /* don't translate \n to \r\n */
62 #endif
63 switch(argc == 2 ? argv[1][0] : 0) {
64 case 'b'://igendian
66 volatile unsigned foo = 0x01234567;
67 puts(*(unsigned char*)&foo == 0x67 ? "no" : "yes");
68 break;
70 #if defined(__clang__)
71 case 'm'://inor
72 printf("%d\n", __clang_minor__);
73 break;
74 case 'v'://ersion
75 printf("%d\n", __clang_major__);
76 break;
77 #elif defined(__TINYC__)
78 case 'v'://ersion
79 puts("0");
80 break;
81 case 'm'://inor
82 printf("%d\n", __TINYC__);
83 break;
84 #elif defined(_MSC_VER)
85 case 'v'://ersion
86 puts("0");
87 break;
88 case 'm'://inor
89 printf("%d\n", _MSC_VER);
90 break;
91 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
92 /* GNU comes last as other compilers may add 'GNU' compatibility */
93 case 'm'://inor
94 printf("%d\n", __GNUC_MINOR__);
95 break;
96 case 'v'://ersion
97 printf("%d\n", __GNUC__);
98 break;
99 #else
100 case 'm'://inor
101 case 'v'://ersion
102 puts("0");
103 break;
104 #endif
105 case 't'://riplet
106 puts(TRIPLET);
107 break;
108 case 'c'://ompiler
109 #if defined(__clang__)
110 puts("clang");
111 #elif defined(__TINYC__)
112 puts("tcc");
113 #elif defined(_MSC_VER)
114 puts("msvc");
115 #elif defined(__GNUC__)
116 puts("gcc");
117 #else
118 puts("unknown");
119 #endif
120 break;
121 default:
122 break;
124 return 0;