digitalmars.D - Cross-platform and D
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (13/21) Nov 22 2004 If you mean to write a portable D library,
- Thomas Kuehne (10/28) Nov 22 2004 Actually it isn't fine.
- =?UTF-8?B?QW5kZXJzIEYgQmrDtnJrbHVuZA==?= (10/22) Nov 22 2004 It could well be that GDC already patches this in
If you mean to write a portable D library, then please try to avoid hardcoding linux... Something that should work is:version(Windows) { // Win32 API stuff } version (Unix) { // POSIX API stuff }But if you use "linux", then your code will *not* compile on BSD - even if it is plain old POSIX ? If you *do* use Linux-specific system / OS values, then by all means continue to use "version(linux)" And if you need stuff specific to GDC / GCC, then you can use the handy "version(GNU)" that it sets... But otherwise, "version(Unix)" should do just fine ? --anders PS. Apple Mac OS X is such a BSD variant... (called Darwin) http://developer.apple.com/darwin/projects/darwin/faq.html
Nov 22 2004
Anders F Björklund schrieb am Mon, 22 Nov 2004 11:36:53 +0100:If you mean to write a portable D library, then please try to avoid hard coding linux... Something that should work is:Actually it isn't fine. GDC defines linux(where appropriate) and Unix - in contrast DMD only defines linux. For the time being everyone should add into the head of each source file ... Seems to be worth a feature request, doesn't it? Thomasversion(Windows) { // Win32 API stuff } version (Unix) { // POSIX API stuff }But if you use "linux", then your code will *not* compile on BSD - even if it is plain old POSIX ? If you *do* use Linux-specific system / OS values, then by all means continue to use "version(linux)" And if you need stuff specific to GDC / GCC, then you can use the handy "version(GNU)" that it sets... But otherwise, "version(Unix)" should do just fine ?
Nov 22 2004
Thomas Kuehne wrote:Aargh! That's even worse than the lower-case "linux"But otherwise, "version(Unix)" should do just fine ?Actually it isn't fine. GDC defines linux(where appropriate) and Unix - in contrast DMD only defines linux. For the time being everyone should addIt could well be that GDC already patches this in Phobos, so that was why I didn't even notice it... Note to self: test with the linux DMD compiler too. I suppose that:version(Windows) else /* version(Unix) */could also be used as a work-around meanwhile ? (better than hardcoding "linux", at any rate)into the head of each source file ... Seems to be worth a feature request, doesn't it?It does. Or even a bug report. --anders
Nov 22 2004