114
|
1 /**
|
|
2 * this module is imported in all modules in the dmd package
|
|
3 * and thus can be used for commonly used aliases etc.
|
|
4 */
|
|
5 module dmd.common;
|
|
6
|
|
7 // versions specified in a module are local to that module even if the module is imported by another one, see code at the bottom
|
|
8 // until a solution is found, at least check the given versions for consistency
|
|
9
|
|
10 pragma(msg, "checking predefined versions for consistency...");
|
|
11
|
|
12 version(DMDV1)
|
|
13 version(DMDV2)
|
|
14 static assert(false, "DMDV1 and DMDV2 can't be set both");
|
|
15
|
|
16 version(DMDV2)
|
|
17 {
|
|
18 version(STRUCTTHISREF) {} else
|
|
19 static assert(false, "DMDV2 requires STRUCTTHISREF. 'this' for struct is a reference");
|
|
20 version(SNAN_DEFAULT_INIT) {} else
|
|
21 static assert(false, "DMDV2 requires SNAN_DEFAULT_INIT. floats are default initialized to signalling NaN");
|
|
22 version(SARRAYVALUE) {} else
|
|
23 static assert(false, "DMDV2 requires SARRAYVALUE. static arrays are value types");
|
|
24 }
|
|
25
|
|
26 version(DMDV2)
|
|
27 version(Posix) // TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS // TODO:
|
|
28 version(CPP_MANGLE) {} else
|
|
29 static assert(false, "CPP_MANGLE must be set if DMDV2 and a Posix target is specified. C++ mangling is done by the front end");
|
|
30
|
|
31 version(Win32)
|
|
32 {
|
|
33 version(_WIN32) {} else
|
|
34 static assert(false, "Set _WIN32 on Win32");
|
|
35 version(TARGET_WINDOS) {} else
|
|
36 static assert(false, "TARGET_WINDOS must be specified on Windows");
|
|
37 version(OMFOBJ) {} else
|
|
38 static assert(false, "OMFOBJ must be used on Windows");
|
|
39 }
|
|
40 else version(Win64)
|
|
41 {
|
|
42 static assert(false, "now we need Win64 support");
|
|
43 }
|
|
44
|
|
45 version(Posix)
|
|
46 version(POSIX) {} else
|
|
47 static assert(false, "POSIX must be set on Posix");
|
|
48
|
|
49 version(TARGET_LINUX)
|
|
50 version(ELFOBJ) {} else
|
|
51 static assert(false, "TARGET_LINUX requires ELFOBJ");
|
|
52 version(TARGET_FREEBSD)
|
|
53 version(ELFOBJ) {} else
|
|
54 static assert(false, "TARGET_FREEBSD requires ELFOBJ");
|
|
55 version(TARGET_SOLARIS)
|
|
56 version(ELFOBJ) {} else
|
|
57 static assert(false, "TARGET_SOLARIS requires ELFOBJ");
|
|
58
|
|
59 version(TARGET_OSX)
|
|
60 version(MACHOBJ) {} else
|
|
61 static assert(false, "TARGET_OSX requires MACHOBJ");
|
|
62
|
|
63
|
|
64 version(IN_GCC) // Changes for the GDC compiler by David Friedman
|
|
65 {
|
|
66 static assert(false, "IN_GCC is not supported");
|
|
67 }
|
|
68
|
|
69 /+
|
|
70 /*
|
|
71 It is very important to use version control macros correctly - the
|
|
72 idea is that host and target are independent. If these are done
|
|
73 correctly, cross compilers can be built.
|
|
74 The host compiler and host operating system are also different,
|
|
75 and are predefined by the host compiler. The ones used in
|
|
76 dmd are:
|
|
77
|
|
78 Macros defined by the compiler, not the code:
|
|
79
|
|
80 Compiler:
|
|
81 __DMC__ Digital Mars compiler
|
|
82 _MSC_VER Microsoft compiler
|
|
83 __GNUC__ Gnu compiler
|
|
84
|
|
85 Host operating system:
|
|
86 _WIN32 Microsoft NT, Windows 95, Windows 98, Win32s,
|
|
87 Windows 2000, Win XP, Vista
|
|
88 _WIN64 Windows for AMD64
|
|
89 linux Linux
|
|
90 __APPLE__ Mac OSX
|
|
91 __FreeBSD__ FreeBSD
|
|
92 __sun&&__SVR4 Solaris, OpenSolaris (yes, both macros are necessary)
|
|
93
|
|
94 For the target systems, there are the target operating system and
|
|
95 the target object file format:
|
|
96
|
|
97 Target operating system:
|
|
98 TARGET_WINDOS Covers 32 bit windows and 64 bit windows
|
|
99 TARGET_LINUX Covers 32 and 64 bit linux
|
|
100 TARGET_OSX Covers 32 and 64 bit Mac OSX
|
|
101 TARGET_FREEBSD Covers 32 and 64 bit FreeBSD
|
|
102 TARGET_SOLARIS Covers 32 and 64 bit Solaris
|
|
103 TARGET_NET Covers .Net
|
|
104
|
|
105 It is expected that the compiler for each platform will be able
|
|
106 to generate 32 and 64 bit code from the same compiler binary.
|
|
107
|
|
108 Target object module format:
|
|
109 OMFOBJ Intel Object Module Format, used on Windows
|
|
110 ELFOBJ Elf Object Module Format, used on linux, FreeBSD and Solaris
|
|
111 MACHOBJ Mach-O Object Module Format, used on Mac OSX
|
|
112
|
|
113 There are currently no macros for byte endianness order.
|
|
114 */
|
|
115 //version definitions from mars.h
|
|
116
|
|
117 pragma(msg, "setting up versions...");
|
|
118
|
|
119 // default to DMDV2
|
|
120 version(DMDV1) {} else
|
|
121 version = DMDV2; // Version 2.0 features
|
|
122 version = BREAKABI; // 0 if not ready to break the ABI just yet
|
|
123 version(DMDV2)
|
|
124 {
|
|
125 version = STRUCTTHISREF; // if 'this' for struct is a reference, not a pointer
|
|
126 version = SNAN_DEFAULT_INIT;// if floats are default initialized to signalling NaN
|
|
127 version = SARRAYVALUE; // static arrays are value types
|
|
128 }
|
|
129
|
|
130 // Set if C++ mangling is done by the front end
|
|
131 version(DMDV2)
|
|
132 {
|
|
133 version(Posix) // TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
|
|
134 version = CPP_MANGLE;
|
|
135 }
|
|
136
|
|
137 /* Other targets are TARGET_LINUX, TARGET_OSX, TARGET_FREEBSD and
|
|
138 * TARGET_SOLARIS, which are
|
|
139 * set on the command line via the compiler makefile.
|
|
140 */
|
|
141
|
|
142 version(Win32)
|
|
143 {
|
|
144 version = _WIN32;
|
|
145 version = TARGET_WINDOS; // Windows dmd generates Windows targets
|
|
146 version = OMFOBJ;
|
|
147 }
|
|
148 else version(Win64)
|
|
149 {
|
|
150 static assert(false, "now we need Win64 support");
|
|
151 }
|
|
152
|
|
153 version(Posix)
|
|
154 version = POSIX;
|
|
155
|
|
156 version(TARGET_LINUX)
|
|
157 version = ELFOBJ;
|
|
158 version(TARGET_FREEBSD)
|
|
159 version = ELFOBJ;
|
|
160 version(TARGET_SOLARIS)
|
|
161 version = ELFOBJ;
|
|
162
|
|
163
|
|
164 version(TARGET_OSX)
|
|
165 version = MACHOBJ;
|
|
166
|
|
167 /* TODO:
|
|
168 //Modify OutBuffer::writewchar to write the correct size of wchar
|
|
169 #if _WIN32
|
|
170 #define writewchar writeword
|
|
171 #else
|
|
172 //This needs a configuration test...
|
|
173 #define writewchar write4
|
|
174 #endif
|
|
175
|
|
176 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry
|
|
177 //in interface vtbl[]'s
|
|
178 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears
|
|
179 //in the inheritance graph multiple
|
|
180 //times, only one is used
|
|
181 */
|
|
182 +/ |