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
|
136
|
63 version(CCASTSYNTAX) {} else
|
|
64 static assert(false, `CCASTSYNTAX is needed for code like "(void*).sizeof"`);
|
|
65
|
|
66 version(CARRAYDECL) {} else
|
|
67 static assert(false, "C array declarations are used in phobos so we still need CARRAYDECL");
|
|
68
|
114
|
69
|
|
70 version(IN_GCC) // Changes for the GDC compiler by David Friedman
|
|
71 {
|
|
72 static assert(false, "IN_GCC is not supported");
|
|
73 }
|
|
74
|
|
75 /+
|
|
76 /*
|
|
77 It is very important to use version control macros correctly - the
|
|
78 idea is that host and target are independent. If these are done
|
|
79 correctly, cross compilers can be built.
|
|
80 The host compiler and host operating system are also different,
|
|
81 and are predefined by the host compiler. The ones used in
|
|
82 dmd are:
|
|
83
|
|
84 Macros defined by the compiler, not the code:
|
|
85
|
|
86 Compiler:
|
|
87 __DMC__ Digital Mars compiler
|
|
88 _MSC_VER Microsoft compiler
|
|
89 __GNUC__ Gnu compiler
|
|
90
|
|
91 Host operating system:
|
|
92 _WIN32 Microsoft NT, Windows 95, Windows 98, Win32s,
|
|
93 Windows 2000, Win XP, Vista
|
|
94 _WIN64 Windows for AMD64
|
|
95 linux Linux
|
|
96 __APPLE__ Mac OSX
|
|
97 __FreeBSD__ FreeBSD
|
|
98 __sun&&__SVR4 Solaris, OpenSolaris (yes, both macros are necessary)
|
|
99
|
|
100 For the target systems, there are the target operating system and
|
|
101 the target object file format:
|
|
102
|
|
103 Target operating system:
|
|
104 TARGET_WINDOS Covers 32 bit windows and 64 bit windows
|
|
105 TARGET_LINUX Covers 32 and 64 bit linux
|
|
106 TARGET_OSX Covers 32 and 64 bit Mac OSX
|
|
107 TARGET_FREEBSD Covers 32 and 64 bit FreeBSD
|
|
108 TARGET_SOLARIS Covers 32 and 64 bit Solaris
|
|
109 TARGET_NET Covers .Net
|
|
110
|
|
111 It is expected that the compiler for each platform will be able
|
|
112 to generate 32 and 64 bit code from the same compiler binary.
|
|
113
|
|
114 Target object module format:
|
|
115 OMFOBJ Intel Object Module Format, used on Windows
|
|
116 ELFOBJ Elf Object Module Format, used on linux, FreeBSD and Solaris
|
|
117 MACHOBJ Mach-O Object Module Format, used on Mac OSX
|
|
118
|
|
119 There are currently no macros for byte endianness order.
|
|
120 */
|
|
121 //version definitions from mars.h
|
|
122
|
|
123 pragma(msg, "setting up versions...");
|
|
124
|
|
125 // default to DMDV2
|
|
126 version(DMDV1) {} else
|
|
127 version = DMDV2; // Version 2.0 features
|
|
128 version = BREAKABI; // 0 if not ready to break the ABI just yet
|
|
129 version(DMDV2)
|
|
130 {
|
|
131 version = STRUCTTHISREF; // if 'this' for struct is a reference, not a pointer
|
|
132 version = SNAN_DEFAULT_INIT;// if floats are default initialized to signalling NaN
|
|
133 version = SARRAYVALUE; // static arrays are value types
|
|
134 }
|
|
135
|
|
136 // Set if C++ mangling is done by the front end
|
|
137 version(DMDV2)
|
|
138 {
|
|
139 version(Posix) // TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
|
|
140 version = CPP_MANGLE;
|
|
141 }
|
|
142
|
|
143 /* Other targets are TARGET_LINUX, TARGET_OSX, TARGET_FREEBSD and
|
|
144 * TARGET_SOLARIS, which are
|
|
145 * set on the command line via the compiler makefile.
|
|
146 */
|
|
147
|
|
148 version(Win32)
|
|
149 {
|
|
150 version = _WIN32;
|
|
151 version = TARGET_WINDOS; // Windows dmd generates Windows targets
|
|
152 version = OMFOBJ;
|
|
153 }
|
|
154 else version(Win64)
|
|
155 {
|
|
156 static assert(false, "now we need Win64 support");
|
|
157 }
|
|
158
|
|
159 version(Posix)
|
|
160 version = POSIX;
|
|
161
|
|
162 version(TARGET_LINUX)
|
|
163 version = ELFOBJ;
|
|
164 version(TARGET_FREEBSD)
|
|
165 version = ELFOBJ;
|
|
166 version(TARGET_SOLARIS)
|
|
167 version = ELFOBJ;
|
|
168
|
|
169
|
|
170 version(TARGET_OSX)
|
|
171 version = MACHOBJ;
|
|
172
|
|
173 /* TODO:
|
|
174 //Modify OutBuffer::writewchar to write the correct size of wchar
|
|
175 #if _WIN32
|
|
176 #define writewchar writeword
|
|
177 #else
|
|
178 //This needs a configuration test...
|
|
179 #define writewchar write4
|
|
180 #endif
|
|
181
|
|
182 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry
|
|
183 //in interface vtbl[]'s
|
|
184 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears
|
|
185 //in the inheritance graph multiple
|
|
186 //times, only one is used
|
|
187 */
|
|
188 +/ |