How to generate D binding with SWIG?

2015-04-06 Thread Suliman via Digitalmars-d-learn
I am still trying to get GDAL[1] work with D. I found tool for automatic binding generation it's named SWIG[2]. I looked at gdal binding examples, and look like all of them are automatically generated with SWIG. I am not sure, but possible binding is generation by one few lines, like is bindin

Conditional compilation for debug/release

2015-04-06 Thread Johan Engelen via Digitalmars-d-learn
How do conditionally compile code for either release ("-release") or debug ("-debug")? Something like this: version(Debug) { pragma(lib, "libcmtd.lib"); } else { pragma(lib, "libcmt.lib"); } In the documentation [1], I don't see any predefined version identifiers for this purpose. Th

Re: Conditional compilation for debug/release

2015-04-06 Thread Namespace via Digitalmars-d-learn
On Monday, 6 April 2015 at 14:50:29 UTC, Johan Engelen wrote: How do conditionally compile code for either release ("-release") or debug ("-debug")? Something like this: version(Debug) { pragma(lib, "libcmtd.lib"); } else { pragma(lib, "libcmt.lib"); } In the documentation [1], I don't

Re: Conditional compilation for debug/release

2015-04-06 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 6 April 2015 at 14:55:58 UTC, Namespace wrote: debug { pragma(lib, "libcmtd.lib"); } else { pragma(lib, "libcmt.lib"); } Thanks for the quick reply! Worth adding an example like that to http://dlang.org/version.html ?

Re: Conditional compilation for debug/release

2015-04-06 Thread Namespace via Digitalmars-d-learn
On Monday, 6 April 2015 at 15:15:48 UTC, Johan Engelen wrote: On Monday, 6 April 2015 at 14:55:58 UTC, Namespace wrote: debug { pragma(lib, "libcmtd.lib"); } else { pragma(lib, "libcmt.lib"); } Thanks for the quick reply! Worth adding an example like that to http://dlang.org/version.h

Re: Conditional compilation for debug/release

2015-04-06 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 6 April 2015 at 15:24:53 UTC, Namespace wrote: On Monday, 6 April 2015 at 15:15:48 UTC, Johan Engelen wrote: On Monday, 6 April 2015 at 14:55:58 UTC, Namespace wrote: debug { pragma(lib, "libcmtd.lib"); } else { pragma(lib, "libcmt.lib"); } Thanks for the quick reply! Worth a

vibed - blocking file I/O via library?

2015-04-06 Thread Laeeth Isharc via Digitalmars-d-learn
So a very basic question about using vibed for a REST service. I am serving data using REST to another application. For the time being it is internal so it is not a disaster if the fiber blocks. But I wanted to understand what I should be doing - the small server app calls library code to re

Re: How to generate D binding with SWIG?

2015-04-06 Thread Jeremy DeHaan via Digitalmars-d-learn
Do you even need to use swig? It looks like gdal has a C interface. I think that htod would be what you're looking for http://dlang.org/htod.html

Re: Issue with free() for linked list implementation

2015-04-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/3/15 6:08 PM, Kitt wrote: On Friday, 3 April 2015 at 22:06:06 UTC, Namespace wrote: On Friday, 3 April 2015 at 22:02:13 UTC, Kitt wrote: Hello. I’m trying to write my own version of a list that doesn’t rely on the garbage collector. I’m working on a very bare bones implementation using mal

Re: Issue with free() for linked list implementation

2015-04-06 Thread Namespace via Digitalmars-d-learn
2. When you malloc, you use 'two.sizeof' and 'ten.sizeof'. Integers are 4 bytes, so you were allocating 4 bytes for each of these (not 2 or 10 bytes as is alluded to above). Yeah, my mistake. I saw the mistake but could not describe it correctly. :)

Re: How to generate D binding with SWIG?

2015-04-06 Thread ddos via Digitalmars-d-learn
On Monday, 6 April 2015 at 15:46:32 UTC, Jeremy DeHaan wrote: Do you even need to use swig? It looks like gdal has a C interface. I think that htod would be what you're looking for http://dlang.org/htod.html +1 for htod if there is a c interface!

UFCS and overloading

2015-04-06 Thread Szymon Gatner via Digitalmars-d-learn
Hi, I am surprised that this doesn't work: class Foo { void bar(string) {} } void bar(Foo foo, int i) { } auto foo = new Foo(); foo.bar(123); // <=== error causing compilation error: main.d(24): Error: function main.Foo.bar (string _param_0) is not callable using argument types (int) do

fromStringz problem with gdc

2015-04-06 Thread chardetm via Digitalmars-d-learn
Hello everyone, I have a problem with the fromStringz function (std.string.fromStringz) when I try to compile with the GDC compiler (it works fine with DMD). Here is a minimal code to see the error: import std.stdio, std.string, std.c.stdlib; int main () { char* s; s = cast(char*)

Re: UFCS and overloading

2015-04-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/6/15 12:23 PM, Szymon Gatner wrote: Hi, I am surprised that this doesn't work: class Foo { void bar(string) {} } void bar(Foo foo, int i) { } auto foo = new Foo(); foo.bar(123); // <=== error causing compilation error: main.d(24): Error: function main.Foo.bar (string _param_0) is no

Re: fromStringz problem with gdc

2015-04-06 Thread Iain Buclaw via Digitalmars-d-learn
On Monday, 6 April 2015 at 17:47:27 UTC, chardetm wrote: Hello everyone, I have a problem with the fromStringz function (std.string.fromStringz) when I try to compile with the GDC compiler (it works fine with DMD). Here is a minimal code to see the error: import std.stdio, std.string, std.

Re: UFCS and overloading

2015-04-06 Thread Szymon Gatner via Digitalmars-d-learn
On Monday, 6 April 2015 at 17:53:13 UTC, Steven Schveighoffer wrote: On 4/6/15 12:23 PM, Szymon Gatner wrote: Hi, I am surprised that this doesn't work: class Foo { void bar(string) {} } void bar(Foo foo, int i) { } auto foo = new Foo(); foo.bar(123); // <=== error causing compilation err

Re: fromStringz problem with gdc

2015-04-06 Thread chardetm via Digitalmars-d-learn
On Monday, 6 April 2015 at 17:55:42 UTC, Iain Buclaw wrote: On Monday, 6 April 2015 at 17:47:27 UTC, chardetm wrote: Hello everyone, I have a problem with the fromStringz function (std.string.fromStringz) when I try to compile with the GDC compiler (it works fine with DMD). Here is a minima

Re: Binary search in structs

2015-04-06 Thread FreeSlave via Digitalmars-d-learn
I think I found solution using opBinaryRight import std.range; struct S { int i; string s; int opCmp(int i) { return this.i - i; } int opCmp(ref const S s) { return this.i - s.i; } int opBinaryRight(string op)(int i) if (op == "<") { return

Re: How to generate D binding with SWIG?

2015-04-06 Thread Suliman via Digitalmars-d-learn
some time ago I tried it, but without success http://forum.dlang.org/thread/hnlrhschfgumaxzgi...@forum.dlang.org

Re: UFCS and overloading

2015-04-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/6/15 2:00 PM, Szymon Gatner wrote: On Monday, 6 April 2015 at 17:53:13 UTC, Steven Schveighoffer wrote: On 4/6/15 12:23 PM, Szymon Gatner wrote: Hi, I am surprised that this doesn't work: class Foo { void bar(string) {} } void bar(Foo foo, int i) { } auto foo = new Foo(); foo.bar(123

Static if to compare two types are the exact same

2015-04-06 Thread Jonathan via Digitalmars-d-learn
What's the best way to do this? I'm assuming this should be best practice: http://dlang.org/traits.html#isSame struct S { } writeln(__traits(isSame, S, S));

Re: Static if to compare two types are the exact same

2015-04-06 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/6/15, Jonathan via Digitalmars-d-learn wrote: > What's the best way to do this? I'm assuming this should be best > practice: > http://dlang.org/traits.html#isSame > > struct S { } > writeln(__traits(isSame, S, S)); > I'm not even sure when or why this trait was introduced, but you could use

Re: Static if to compare two types are the exact same

2015-04-06 Thread ketmar via Digitalmars-d-learn
On Mon, 06 Apr 2015 19:16:33 +, Jonathan wrote: > What's the best way to do this? I'm assuming this should be best > practice: > http://dlang.org/traits.html#isSame > > struct S { } > writeln(__traits(isSame, S, S)); struct S {} auto s0 = S(); auto s1 = S(); static if (is(typeof(s0) == ty

Re: fromStringz problem with gdc

2015-04-06 Thread bachmeier via Digitalmars-d-learn
On Monday, 6 April 2015 at 18:31:13 UTC, chardetm wrote: On Monday, 6 April 2015 at 17:55:42 UTC, Iain Buclaw wrote: On Monday, 6 April 2015 at 17:47:27 UTC, chardetm wrote: Hello everyone, I have a problem with the fromStringz function (std.string.fromStringz) when I try to compile with the

D1: Out of memory problems

2015-04-06 Thread jicman via Digitalmars-d-learn
Greetings. I am using, 15:32:35.63>dmd Digital Mars D Compiler v1.046 Copyright (c) 1999-2009 by Digital Mars written by Walter Bright Documentation: http://www.digitalmars.com/d/1.0/index.html And I have a program that reads a file into UTF8 and does a series of string handling to create rep

D1 -> D2 Code converter

2015-04-06 Thread jicman via Digitalmars-d-learn
Greetings! Has anyone written any quick program to convert d1 code to d2? I believe it will be a fine piece of program. :-) Thanks. josé

Re: D1 -> D2 Code converter

2015-04-06 Thread Dicebot via Digitalmars-d-learn
On Monday, 6 April 2015 at 20:25:39 UTC, jicman wrote: Greetings! Has anyone written any quick program to convert d1 code to d2? I believe it will be a fine piece of program. :-) Thanks. josé It is surprisingly difficult, to the point of being almost impossible, to write such program. P

Troubles with devisualization/window

2015-04-06 Thread ddos via Digitalmars-d-learn
Hi! i'm trying to get devisualization/window [1] working with some simple opengl calls. I have created a windows with opengl context using Window window = new Window(800, 600, "My window!"w, WindowContextType.Opengl); If i run writeln("type: ", context.type); writeln("toolkit version: ", c

getting started with std.csv

2015-04-06 Thread gjansen via Digitalmars-d-learn
Hi. I'm a D newbie(!) coming from a Fortran/C/Python background. I'm struggling with the many new concepts needed in order to make any sense out of the documentation or traceback messages (ranges/templates/...). For example, the std.csv documentation is great but all the examples read from a st

Re: Troubles with devisualization/window

2015-04-06 Thread Rikki Cattermole via Digitalmars-d-learn
On 7/04/2015 10:07 a.m., ddos wrote: Hi! i'm trying to get devisualization/window [1] working with some simple opengl calls. I have created a windows with opengl context using Window window = new Window(800, 600, "My window!"w, WindowContextType.Opengl); If i run writeln("type: ", context.type

Re: Troubles with devisualization/window

2015-04-06 Thread ddos via Digitalmars-d-learn
it's getting warmer, window doesnt freeze anymore and opengl calls don't crash the window, but it's still all white after calling glClearColor(1,0,1,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); updated src: https://github.com/oggs91/OpenVG_D/blob/master/demo_DvisualizationWT/source/

Re: Troubles with devisualization/window

2015-04-06 Thread Rikki Cattermole via Digitalmars-d-learn
On 7/04/2015 10:34 a.m., ddos wrote: it's getting warmer, window doesnt freeze anymore and opengl calls don't crash the window, but it's still all white after calling glClearColor(1,0,1,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); updated src: https://github.com/oggs91/OpenVG_D/blob/m

Re: Troubles with devisualization/window

2015-04-06 Thread ddos via Digitalmars-d-learn
On Monday, 6 April 2015 at 22:56:15 UTC, Rikki Cattermole wrote: On 7/04/2015 10:34 a.m., ddos wrote: it's getting warmer, window doesnt freeze anymore and opengl calls don't crash the window, but it's still all white after calling glClearColor(1,0,1,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_B

Re: Troubles with devisualization/window

2015-04-06 Thread Rikki Cattermole via Digitalmars-d-learn
On 7/04/2015 12:10 p.m., ddos wrote: On Monday, 6 April 2015 at 22:56:15 UTC, Rikki Cattermole wrote: On 7/04/2015 10:34 a.m., ddos wrote: it's getting warmer, window doesnt freeze anymore and opengl calls don't crash the window, but it's still all white after calling glClearColor(1,0,1,1); glC

Re: D1 -> D2 Code converter

2015-04-06 Thread jicman via Digitalmars-d-learn
On Monday, 6 April 2015 at 20:48:05 UTC, Dicebot wrote: On Monday, 6 April 2015 at 20:25:39 UTC, jicman wrote: Greetings! Has anyone written any quick program to convert d1 code to d2? I believe it will be a fine piece of program. :-) Thanks. josé It is surprisingly difficult, to the poin

Strange behavior std.range.takeNone

2015-04-06 Thread Dennis Ritchie via Digitalmars-d-learn
Hi, Is it OK? - import std.stdio : writeln; import std.range : takeNone; void main() { auto s = takeNone("test"); s ~= 5; writeln(s); // prints ♣ } - Windows 8.1 x64, DMD 2.067.0

Re: Strange behavior std.range.takeNone

2015-04-06 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 02:24:00 UTC, Dennis Ritchie wrote: Is it OK? Although, perhaps, everything is fine. I just thought that creates takeNone not string type string, and the string array of type string[]. import std.stdio : writeln; void main() { string s; s ~= 5;

Re: getting started with std.csv

2015-04-06 Thread yazd via Digitalmars-d-learn
I got this to work with: ``` import std.stdio, std.file, std.csv, std.range; void main() { std.file.write("test.csv", "0,1,abc\n2,3,def"); scope(exit) std.file.remove("test.csv"); static struct Rec { int a, b; char[] c; } auto file = File("test.csv", "r");

Re: getting started with std.csv

2015-04-06 Thread yazd via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 05:49:48 UTC, yazd wrote: I got this to work with: ``` import std.stdio, std.file, std.csv, std.range; void main() { std.file.write("test.csv", "0,1,abc\n2,3,def"); scope(exit) std.file.remove("test.csv"); static struct Rec { int a, b; char[]

Re: Static if to compare two types are the exact same

2015-04-06 Thread Jonathan via Digitalmars-d-learn
static if (is(T == V)) Are static ifs always checked outside of runtime? Is it possible for a static if condition to be undeterminable outside of runtime, or would such a condition throw a compiler error?