Re: Binding Nested C Structs

2015-07-09 Thread Craig Dillabaugh via Digitalmars-d-learn
On Friday, 10 July 2015 at 03:38:49 UTC, Craig Dillabaugh wrote: I am trying to bind to a C union with a number of nested structs declared as follows: typedef union { int Integer; struct { int nCount; int *paList; } IntegerList; struct {

Binding Nested C Structs

2015-07-09 Thread Craig Dillabaugh via Digitalmars-d-learn
I am trying to bind to a C union with a number of nested structs declared as follows: typedef union { int Integer; struct { int nCount; int *paList; } IntegerList; struct { int nCount; GIntBig *paList; } Integer64List; }

Re: Fixed Length Array Syntax in extern(C) Function Signatures

2015-07-09 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 9 July 2015 at 17:42:33 UTC, Alex Parrill wrote: On Thursday, 9 July 2015 at 17:11:36 UTC, Per Nordlöw wrote: On Thursday, 9 July 2015 at 16:12:27 UTC, Timon Gehr wrote: No. You'll need explicit pass by reference on the D side. So, how should I modify my call to `image_copy` with

Re: Import module

2015-07-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 10 July 2015 at 00:53:38 UTC, codenstuff wrote: The path is ${HOME}/d_apps/steering/steering/game_object.d Compile command is dmd map/map.d main_visual.d -ofmain_visual -H -gc -unittest -L-lDgame -L-lDerelictUtil -L-lDerelictGL3 -L-lDerelictSDL2 -L-ldl -I/home/real/d_apps/dgame/so

Re: Import module

2015-07-09 Thread codenstuff via Digitalmars-d-learn
On Friday, 10 July 2015 at 00:24:44 UTC, anonymous wrote: On Thursday, 9 July 2015 at 22:05:23 UTC, codenstuff wrote: I am trying to import module and compile. The compiler produces message map/map.d(9): Error: module game_object is in file 'steering/game_object.d' which cannot be read impor

Re: Import module

2015-07-09 Thread anonymous via Digitalmars-d-learn
On Thursday, 9 July 2015 at 22:05:23 UTC, codenstuff wrote: I am trying to import module and compile. The compiler produces message map/map.d(9): Error: module game_object is in file 'steering/game_object.d' which cannot be read import path[0] = /usr/include/dmd/phobos import path[1] = /usr/i

Re: Import module

2015-07-09 Thread codenstuff via Digitalmars-d-learn
On Thursday, 9 July 2015 at 22:10:53 UTC, Adam D. Ruppe wrote: The best thing to do is to pass all the modules in the project to the compiler at once, so like: dmd map/map.d steering/game_object.d The import path could be changed to not include the steering/ folder - give it the folder that c

Re: Import module

2015-07-09 Thread Adam D. Ruppe via Digitalmars-d-learn
The best thing to do is to pass all the modules in the project to the compiler at once, so like: dmd map/map.d steering/game_object.d The import path could be changed to not include the steering/ folder - give it the folder that contains steering - but that still won't actually link without a

Import module

2015-07-09 Thread codenstuff via Digitalmars-d-learn
I am trying to import module and compile. The compiler produces message map/map.d(9): Error: module game_object is in file 'steering/game_object.d' which cannot be read import path[0] = /usr/include/dmd/phobos import path[1] = /usr/include/dmd/druntime/import make: *** [main] Error 1 How can

Re: I'm getting NAN out of nowhere

2015-07-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/9/15 1:04 PM, bachmeier wrote: On Thursday, 9 July 2015 at 15:18:18 UTC, Adam D. Ruppe wrote: On Thursday, 9 July 2015 at 15:14:43 UTC, Binarydepth wrote: float prom; You didn't initialize this variable. Set it to 0.0 and it will work. Like how pointers are initialized to null autom

Re: Fixed Length Array Syntax in extern(C) Function Signatures

2015-07-09 Thread Alex Parrill via Digitalmars-d-learn
On Thursday, 9 July 2015 at 17:11:36 UTC, Per Nordlöw wrote: On Thursday, 9 July 2015 at 16:12:27 UTC, Timon Gehr wrote: No. You'll need explicit pass by reference on the D side. So, how should I modify my call to `image_copy` with respect to the four first parameters? In C, array parameter

Re: Fixed Length Array Syntax in extern(C) Function Signatures

2015-07-09 Thread via Digitalmars-d-learn
On Thursday, 9 July 2015 at 16:12:27 UTC, Timon Gehr wrote: No. You'll need explicit pass by reference on the D side. So, how should I modify my call to `image_copy` with respect to the four first parameters?

Re: I'm getting NAN out of nowhere

2015-07-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 9 July 2015 at 17:04:43 UTC, bachmeier wrote: Is there a reason the compiler doesn't identify this as an error? The compiler just doesn't really try to trace if variables have actually been initialized or not. It punts it to runtime for simplicity of compiler implementation.

Re: I'm getting NAN out of nowhere

2015-07-09 Thread bachmeier via Digitalmars-d-learn
On Thursday, 9 July 2015 at 15:18:18 UTC, Adam D. Ruppe wrote: On Thursday, 9 July 2015 at 15:14:43 UTC, Binarydepth wrote: float prom; You didn't initialize this variable. Set it to 0.0 and it will work. Like how pointers are initialized to null automatically in D, floats are auto

Re: How to get value of enum without casting

2015-07-09 Thread Justin Whear via Digitalmars-d-learn
On Thu, 09 Jul 2015 16:20:56 +, tcak wrote: > Is there any way to get the type of enum without interacting with its > items? std.traits.OriginalType > Is there any way to get string representation of an item of enum without > casting? I think casting to the OriginalType and then using to!stri

How to get value of enum without casting

2015-07-09 Thread tcak via Digitalmars-d-learn
[code] const enum FieldLength: uint{ Title = 64 } const string SQL1 = "title CHAR(" ~ std.conv.to!string( FieldLength.Title ) ~ ")"; void main() { writeln( FieldLength.Title ); writeln( SQL1 ); } [/code] Result is --- Title Char(Title) I can do cast(uint

Re: Fixed Length Array Syntax in extern(C) Function Signatures

2015-07-09 Thread Timon Gehr via Digitalmars-d-learn
On 07/09/2015 05:19 PM, "Nordlöw" wrote: Given extern(C): struct AVFrame { uint8_t*[AV_NUM_DATA_POINTERS] data; int[AV_NUM_DATA_POINTERS] linesize; int width, height; ... } void av_image_copy(ubyte *[4] dst_data, int[4] dst_linesizes

Re: Fixed Length Array Syntax in extern(C) Function Signatures

2015-07-09 Thread Nordlöw
On Thursday, 9 July 2015 at 15:19:41 UTC, Nordlöw wrote: uint8_t*[AV_NUM_DATA_POINTERS] data; int[AV_NUM_DATA_POINTERS] linesize; Forgot enum AV_NUM_DATA_POINTERS = 8;

Re: I'm getting NAN out of nowhere

2015-07-09 Thread Binarydepth via Digitalmars-d-learn
On Thursday, 9 July 2015 at 15:18:18 UTC, Adam D. Ruppe wrote: On Thursday, 9 July 2015 at 15:14:43 UTC, Binarydepth wrote: float prom; You didn't initialize this variable. Set it to 0.0 and it will work. Like how pointers are initialized to null automatically in D, floats are auto

Re: I'm getting NAN out of nowhere

2015-07-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 9 July 2015 at 15:14:43 UTC, Binarydepth wrote: float prom; You didn't initialize this variable. Set it to 0.0 and it will work. Like how pointers are initialized to null automatically in D, floats are auto initalized to NaN in D. The idea is to make use of an uninitia

Fixed Length Array Syntax in extern(C) Function Signatures

2015-07-09 Thread Nordlöw
Given extern(C): struct AVFrame { uint8_t*[AV_NUM_DATA_POINTERS] data; int[AV_NUM_DATA_POINTERS] linesize; int width, height; ... } void av_image_copy(ubyte *[4] dst_data, int[4] dst_linesizes, const ubyte *[4] src_data,

I'm getting NAN out of nowhere

2015-07-09 Thread Binarydepth via Digitalmars-d-learn
This is my code : import std.stdio : writeln, readf; void main() { int[3] nums; float prom; foreach(nem; 0..2) { writeln("input a number : "); readf(" %d", &nums[nem]); prom+=nums[nem]; } writeln(prom/

Re: Wrapping a C-style Array (Pointer + Length) in a Range Interface

2015-07-09 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 7 July 2015 at 12:26:33 UTC, Per Nordlöw wrote: I'm currently developing a high-level wrapper for FFMPEG at https://github.com/nordlow/justd/blob/master/tests/t_ffmpeg.d My question now becomes how to most easily wrap the iteration over streams at https://github.com/nordlow/justd

Re: Understanding Safety of Function Pointers vs. Addresses of Functions

2015-07-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/9/15 4:44 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= " wrote: On Wednesday, 8 July 2015 at 21:04:27 UTC, jmh530 wrote: On Wednesday, 8 July 2015 at 18:31:00 UTC, Steven Schveighoffer wrote: You can use a function lambda: auto fp = (real a) => cos(a); Note, I had to put (real a) even though I wou

Re: How to keep executed shell running after program exits

2015-07-09 Thread via Digitalmars-d-learn
On Thursday, 9 July 2015 at 02:33:23 UTC, tcak wrote: BTW, as a tutorial to demonstrate use of gnuplot with D, is there any place I can write an article? http://wiki.dlang.org/Tutorials

Re: How to keep executed shell running after program exits

2015-07-09 Thread via Digitalmars-d-learn
On Thursday, 9 July 2015 at 02:33:23 UTC, tcak wrote: I have written a code to run gnuplot. [code] ... auto script = std.stdio.File("/tmp/waveletscript.gnuplot", "w"); script.writeln("set term wxt 1; plot '/tmp/wavelet1.dat';"); script.writeln("set term wxt 2; plot '/tmp/wavelet2.dat';"); scrip

Re: Understanding Safety of Function Pointers vs. Addresses of Functions

2015-07-09 Thread via Digitalmars-d-learn
On Wednesday, 8 July 2015 at 21:04:27 UTC, jmh530 wrote: On Wednesday, 8 July 2015 at 18:31:00 UTC, Steven Schveighoffer wrote: You can use a function lambda: auto fp = (real a) => cos(a); Note, I had to put (real a) even though I would have expected "a => cos(a)" to work. -Steve Interest