www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Attributes problems (any ideas for a fix... maybe []?)

reply hellcatv hotmail.com writes:
Attributes are pretty good, but they need another form
I need to be able to do

version(UseWindowExports) {
[extern (Windows):]
}else {
[extern (C):]
}
void glStipple (int, short);

right now the colon ends at the next closing brace
I want it to survive ONE extra closing brace... or until the next attribute.
if I take out the closing brace, then I have to write the glStipple (n) times
where n is the number of versions of the lib I want to make

can anyone help think of some syntax to fix this..it really makes writing
cross-platform headers quite unfeasable the way it is. 

the language needs ways to make cross-platform headers with different linkages
specified on a per-version basis... I can't have gl_sgi.h gl_mac.h gl_windows.h
gl_linux.h gl_ppclinux.h(different ABI)

--Daniel
May 08 2004
next sibling parent reply "Carlos Santander B." <carlos8294 msn.com> writes:
<hellcatv hotmail.com> wrote in message news:c7k0kq$2vvs$1 digitaldaemon.com
| Attributes are pretty good, but they need another form
| I need to be able to do
|
| version(UseWindowExports) {
| [extern (Windows):]
| }else {
| [extern (C):]
| }
| void glStipple (int, short);
|
| right now the colon ends at the next closing brace
| I want it to survive ONE extra closing brace... or until the next
attribute.
| if I take out the closing brace, then I have to write the glStipple (n)
times
| where n is the number of versions of the lib I want to make
|
| can anyone help think of some syntax to fix this..it really makes writing
| cross-platform headers quite unfeasable the way it is.
|
| the language needs ways to make cross-platform headers with different
linkages
| specified on a per-version basis... I can't have gl_sgi.h gl_mac.h
gl_windows.h
| gl_linux.h gl_ppclinux.h(different ABI)
|
| --Daniel

You can omit the braces:
version(Windows)
    extern(Windows):
else
    extern(C):

-----------------------
Carlos Santander Bernal
May 08 2004
parent reply hellcatv hotmail.com writes:
In article <c7k51f$43n$1 digitaldaemon.com>, Carlos Santander B. says...
<hellcatv hotmail.com> wrote in message news:c7k0kq$2vvs$1 digitaldaemon.com
| Attributes are pretty good, but they need another form
| I need to be able to do
|
| version(UseWindowExports) {
| [extern (Windows):]
| }else {
| [extern (C):]
| }
| void glStipple (int, short);
|
| right now the colon ends at the next closing brace
| I want it to survive ONE extra closing brace... or until the next
attribute.
| if I take out the closing brace, then I have to write the glStipple (n)
times
| where n is the number of versions of the lib I want to make
|
| can anyone help think of some syntax to fix this..it really makes writing
| cross-platform headers quite unfeasable the way it is.
|
| the language needs ways to make cross-platform headers with different
linkages
| specified on a per-version basis... I can't have gl_sgi.h gl_mac.h
gl_windows.h
| gl_linux.h gl_ppclinux.h(different ABI)
|
| --Daniel

You can omit the braces:
version(Windows)
    extern(Windows):
else
    extern(C):

what if I had export void glEnd(); would that go undefined in the windows version? or does the version command stop on the colon. can I have some dummy statement next?
May 09 2004
parent "Carlos Santander B." <carlos8294 msn.com> writes:
<hellcatv hotmail.com> wrote in message news:c7l24k$1fj7$1 digitaldaemon.com
| In article <c7k51f$43n$1 digitaldaemon.com>, Carlos Santander B. says...
||
|| You can omit the braces:
|| version(Windows)
||    extern(Windows):
|| else
||    extern(C):
| does that invalidate the next statement for windows?
| what if I had
| export void glEnd();
|
| would that go undefined in the windows version? or does the version
command stop
| on the colon.
| can I have some dummy statement next?

I don't think it'll go undefined. However you can try and see what happens.

-----------------------
Carlos Santander Bernal
May 09 2004
prev sibling parent reply "Vathix" <vathixSpamFix dprogramming.com> writes:
<hellcatv hotmail.com> wrote in message
news:c7k0kq$2vvs$1 digitaldaemon.com...
 Attributes are pretty good, but they need another form
 I need to be able to do

 version(UseWindowExports) {
 [extern (Windows):]
 }else {
 [extern (C):]
 }
 void glStipple (int, short);

 right now the colon ends at the next closing brace
 I want it to survive ONE extra closing brace... or until the next

 if I take out the closing brace, then I have to write the glStipple (n)

 where n is the number of versions of the lib I want to make

 can anyone help think of some syntax to fix this..it really makes writing
 cross-platform headers quite unfeasable the way it is.

 the language needs ways to make cross-platform headers with different

 specified on a per-version basis... I can't have gl_sgi.h gl_mac.h

 gl_linux.h gl_ppclinux.h(different ABI)

 --Daniel

I think something like this would fit in better: version(Something) alias extern(Windows) foo; else alias extern(C) foo; extern(foo): void stuff();
May 08 2004
parent Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
My first thought is to say this looks like a good idea.  But my second 
thought says that alias is starting to look more and more like a macro 
language...

Vathix wrote:
 I think something like this would fit in better:
 
 version(Something)
    alias extern(Windows) foo;
 else
    alias extern(C) foo;
 extern(foo):
 void stuff();

May 11 2004