View mode: basic / threaded / horizontal-split · Log in · Help
January 07, 2004
in/inout Optimisation Question
What happens when you pass a struct into a function as "in" and only 
read from that variable.

ie

struct foo {int x, y, z, w;}

void func(in foo g)
{
   int x = g.x;
}

Will the compiler optimise this to a reference, or will it copy the 
entire struct on to the stack? Am I better to use inout or a pointer?

Anderson
May 18, 2004
Re: in/inout Optimisation Question
"J Anderson" <REMOVEanderson@badmama.com.au> wrote in message
news:bthn5h$2j1b$1@digitaldaemon.com...
> What happens when you pass a struct into a function as "in" and only
> read from that variable.
>
> ie
>
> struct foo {int x, y, z, w;}
>
> void func(in foo g)
> {
>     int x = g.x;
> }
>
> Will the compiler optimise this to a reference, or will it copy the
> entire struct on to the stack? Am I better to use inout or a pointer?

The compiler can do either as long as the results are the same. Whether
using a pointer is faster or not depends on the details of the CPU, the size
of the struct, how it's used inside the function, etc.
April 09, 2005
creating *.so libs, under linux
Hello, 

I was wondering when will it be possible (I beleive its not yet supported) to create code for dynamically loaded
libraries under linux/unix. That is, position independent code, like with the -fpic switch on gcc compiler.

Also, will the dynamic library loading/unloading be part of the standard D ? So that you can use these libs same on windows and linux say.
April 09, 2005
Re: creating *.so libs, under linux
Denis R wrote:

> Hello,
> 
> I was wondering when will it be possible (I beleive its not yet supported)
> to create code for dynamically loaded libraries under linux/unix. That is,
> position independent code, like with the -fpic switch on gcc compiler.
> 
> Also, will the dynamic library loading/unloading be part of the standard D
> ? So that you can use these libs same on windows and linux say.

GDC can (http://home.earthlink.net/~dvdfrdmn/d/)

On windows there is std.loader, however loader isn't included in the linux
libphobos.a for some reason, I don't know why, you can add it yourself by
adding loader.d to the command line.

The Derelict project has its own x-platform loader. (derelict.util.*)
(www.dsource.org/projects/derelict)
Top | Discussion index | About this forum | D home