digitalmars.D.learn - attribute decl in version decl
- Ellery Newcomer (7/7) Sep 18 2011 Just came across some old D code that does this:
- Timon Gehr (5/12) Sep 18 2011 Yes they should be applied, unless they declare D functions, which is
- Ellery Newcomer (2/5) Sep 18 2011 Nah, just confirming that failure to apply the externs is a bug.
- Timon Gehr (9/14) Sep 18 2011 version(linux){
- Trass3r (5/12) Sep 18 2011 Walter once said it was deliberate.
- Ellery Newcomer (3/22) Sep 18 2011 Really.
- Daniel Murphy (5/9) Sep 18 2011 Are the prototypes extern(Windows) when not on linux, by any chance? Th...
- Ellery Newcomer (2/16) Sep 19 2011 yep. didn't know about System. Thanks.
- Mike Parker (4/11) Sep 19 2011 Change it to the following, and you're golden.
- Trass3r (10/13) Sep 19 2011 That only fixes this particular issue.
- Timon Gehr (7/22) Sep 19 2011 You could use the C preprocessor ;). Or this, that does the same thing:
-
Ellery Newcomer
(15/23)
Sep 19 2011
Just came across some old D code that does this: version(linux){ extern(C): } <Hundreds of OpenGL decls> in dmd 2.055, the extern(C) is not being applied to the OpenGL decls. should it?
Sep 18 2011
On 09/18/2011 06:55 PM, Ellery Newcomer wrote:Just came across some old D code that does this: version(linux){ extern(C): } <Hundreds of OpenGL decls> in dmd 2.055, the extern(C) is not being applied to the OpenGL decls. should it?Yes they should be applied, unless they declare D functions, which is seldom the case for <Hundreds of OpenGL decls>. If you are asking, if the D compiler is wrong here: No, it is by design, you can check with the D grammar.
Sep 18 2011
On 09/18/2011 01:02 PM, Timon Gehr wrote:If you are asking, if the D compiler is wrong here: No, it is by design, you can check with the D grammar.Nah, just confirming that failure to apply the externs is a bug.
Sep 18 2011
On 09/18/2011 10:46 PM, Ellery Newcomer wrote:On 09/18/2011 01:02 PM, Timon Gehr wrote:version(linux){ extern(C): } // affected declarations end here, because '}' is not a declaration. ConditionalDeclarations don't work like the C preprocessor, the code is parsed before the ConditionalDeclaration is applied, not the other way round. It would indeed be desirable to have it work like this, but it would be a special case.If you are asking, if the D compiler is wrong here: No, it is by design, you can check with the D grammar.Nah, just confirming that failure to apply the externs is a bug.
Sep 18 2011
Am 18.09.2011, 18:55 Uhr, schrieb Ellery Newcomer <ellery-newcomer utulsa.edu>:Just came across some old D code that does this: version(linux){ extern(C): } <Hundreds of OpenGL decls> in dmd 2.055, the extern(C) is not being applied to the OpenGL decls. should it?Walter once said it was deliberate. That extern(C) is only valid inside the version block. But I also think it should be the other way around.
Sep 18 2011
On 09/18/2011 04:09 PM, Trass3r wrote:Am 18.09.2011, 18:55 Uhr, schrieb Ellery Newcomer <ellery-newcomer utulsa.edu>:Really. Wonder how gunroar ever compiledJust came across some old D code that does this: version(linux){ extern(C): } <Hundreds of OpenGL decls> in dmd 2.055, the extern(C) is not being applied to the OpenGL decls. should it?Walter once said it was deliberate. That extern(C) is only valid inside the version block. But I also think it should be the other way around.
Sep 18 2011
"Ellery Newcomer" <ellery-newcomer utulsa.edu> wrote in message news:j557r6$vgt$1 digitalmars.com...Just came across some old D code that does this: version(linux){ extern(C): }Are the prototypes extern(Windows) when not on linux, by any chance? That is the only combination I've ever had to use, and is supported by extern(System).
Sep 18 2011
On 09/18/2011 11:04 PM, Daniel Murphy wrote:"Ellery Newcomer" <ellery-newcomer utulsa.edu> wrote in message news:j557r6$vgt$1 digitalmars.com...yep. didn't know about System. Thanks.Just came across some old D code that does this: version(linux){ extern(C): }Are the prototypes extern(Windows) when not on linux, by any chance? That is the only combination I've ever had to use, and is supported by extern(System).
Sep 19 2011
On 9/19/2011 1:55 AM, Ellery Newcomer wrote:Just came across some old D code that does this: version(linux){ extern(C): } <Hundreds of OpenGL decls> in dmd 2.055, the extern(C) is not being applied to the OpenGL decls. should it?Change it to the following, and you're golden. extern(System): <Hundreds of OpenGL decls>
Sep 19 2011
Change it to the following, and you're golden. extern(System): <Hundreds of OpenGL decls>That only fixes this particular issue. I once had the following case that can't be done: version(V1) { extern(System): } else { extern(C): }
Sep 19 2011
On 09/19/2011 03:37 PM, Trass3r wrote:You could use the C preprocessor ;). Or this, that does the same thing: version(V1) private enum _v1=true; else private enum _v1=false; mixin((_v1?"extern(System):":"extern(C):")~q{ // all declarations that should be affected. });Change it to the following, and you're golden. extern(System): <Hundreds of OpenGL decls>That only fixes this particular issue. I once had the following case that can't be done: version(V1) { extern(System): } else { extern(C): }
Sep 19 2011
On 09/19/2011 08:59 AM, Timon Gehr wrote:You could use the C preprocessor ;). Or this, that does the same thing: version(V1) private enum _v1=true; else private enum _v1=false; mixin((_v1?"extern(System):":"extern(C):")~q{ // all declarations that should be affected. });<code golf> or this: version(linux){ extern(C): mixin(s); } version(Win32){ extern(Windows): mixin(s); } enum s = q{ <hundreds of opengl decls> }; </code golf>
Sep 19 2011