Re: Access Violation when passing the result of a C function directly to a D function?

2017-09-15 Thread Vadim Lopatin via Digitalmars-d-learn
On Friday, 15 September 2017 at 04:01:13 UTC, Timothy Foster wrote: I'm compiling on Windows 7 x64, DMD32 D Compiler v2.075.1 and I'm using Derelict Fmod to handle audio in my application. Every Fmod function returns an int telling me if the function ran okay, or if there was an error. I've

Re: Internal error mixing templates and CTFE

2017-09-15 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 15 September 2017 at 05:58:47 UTC, David Bennett wrote: Hi Guys, I've been playing around with CTFE today to see how far I would push it but I'm having an issue appending to an array on a struct in CTFE from a template: [...] are you using ucent ?

Re: failed loading freetype 2.6 via derelict-ft

2017-09-15 Thread Spacen via Digitalmars-d-learn
On Friday, 15 September 2017 at 05:16:55 UTC, Mike Parker wrote: On Wednesday, 13 September 2017 at 22:18:07 UTC, Mike Parker wrote: Missing symbols usually mean a version mismatch. The latest DerelictFT requires FreeType 2.6 or later. It could also mean your shared library was compiled

Re: extern(C) enum

2017-09-15 Thread bitwise via Digitalmars-d-learn
On Friday, 15 September 2017 at 07:24:34 UTC, Jonathan M Davis wrote: On Friday, September 15, 2017 04:15:57 bitwise via Digitalmars-d-learn wrote: I translated the headers for FreeType2 to D, and in many cases, enums are used as struct members. If I declare an extern(C) enum in D, is it

Re: extern(C) enum

2017-09-15 Thread bitwise via Digitalmars-d-learn
On Friday, 15 September 2017 at 06:57:31 UTC, rikki cattermole wrote: On 15/09/2017 5:15 AM, bitwise wrote: I translated the headers for FreeType2 to D, and in many cases, enums are used as struct members. If I declare an extern(C) enum in D, is it guaranteed to have the same underlying type

Re: extern(C) enum

2017-09-15 Thread Timothy Foster via Digitalmars-d-learn
On Friday, 15 September 2017 at 15:35:48 UTC, bitwise wrote: On Friday, 15 September 2017 at 07:24:34 UTC, Jonathan M Davis wrote: On Friday, September 15, 2017 04:15:57 bitwise via Digitalmars-d-learn wrote: I translated the headers for FreeType2 to D, and in many cases, enums are used as

Re: extern(C) enum

2017-09-15 Thread nkm1 via Digitalmars-d-learn
On Friday, 15 September 2017 at 19:21:02 UTC, Timothy Foster wrote: I believe C enum size is implementation defined. A C compiler can pick the underlying type (1, 2, or 4 bytes, signed or unsigned) that fits the values in the enum. No, at least, not C99. See 6.4.4.3: "An identifier declared

Re: extern(C) enum

2017-09-15 Thread jmh530 via Digitalmars-d-learn
On Friday, 15 September 2017 at 18:20:06 UTC, Jonathan M Davis wrote: It is my understanding that for both C and C++, an enum is always an int (unless you're talking about enum classes in C++). The size of an int can change based on your architecture, but AFAIK, all of the architectures

Re: Ranges suck!

2017-09-15 Thread bitwise via Digitalmars-d-learn
On Thursday, 14 September 2017 at 23:53:20 UTC, Your name wrote: [...] I understand your frustration. The fact that "inout" is actually a keyword makes it hard not to think that some very strange fetishes were at play during the creation of this language. As a whole though, the language

Re: extern(C) enum

2017-09-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 15, 2017 15:35:48 bitwise via Digitalmars-d-learn wrote: > On Friday, 15 September 2017 at 07:24:34 UTC, Jonathan M Davis > > wrote: > > On Friday, September 15, 2017 04:15:57 bitwise via > > > > Digitalmars-d-learn wrote: > >> I translated the headers for FreeType2 to D, and

Re: Access Violation when passing the result of a C function directly to a D function?

2017-09-15 Thread Timothy Foster via Digitalmars-d-learn
On Friday, 15 September 2017 at 10:33:55 UTC, Vadim Lopatin wrote: On Friday, 15 September 2017 at 04:01:13 UTC, Timothy Foster wrote: [...] Probably you have to use const char * msg when interfacing with C. string is a struct - size_t length and const char * value The string doesn't touch

Re: Access Violation when passing the result of a C function directly to a D function?

2017-09-15 Thread Kagamin via Digitalmars-d-learn
On Friday, 15 September 2017 at 04:01:13 UTC, Timothy Foster wrote: am I required to save the result of a C function to variable before passing it into another function or? No. You probably have stack corruption. Does it crash if FMOD_System_Create returns ok?

Re: Access Violation when passing the result of a C function directly to a D function?

2017-09-15 Thread Timothy Foster via Digitalmars-d-learn
On Friday, 15 September 2017 at 16:55:27 UTC, Kagamin wrote: On Friday, 15 September 2017 at 04:01:13 UTC, Timothy Foster wrote: am I required to save the result of a C function to variable before passing it into another function or? No. You probably have stack corruption. Does it crash if

Re: extern(C) enum

2017-09-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 15, 2017 04:15:57 bitwise via Digitalmars-d-learn wrote: > I translated the headers for FreeType2 to D, and in many cases, > enums are used as struct members. > > If I declare an extern(C) enum in D, is it guaranteed to have the > same underlying type and size as it would for

Re: extern(C) enum

2017-09-15 Thread rikki cattermole via Digitalmars-d-learn
On 15/09/2017 5:15 AM, bitwise wrote: I translated the headers for FreeType2 to D, and in many cases, enums are used as struct members. If I declare an extern(C) enum in D, is it guaranteed to have the same underlying type and size as it would for a C compiler on the same platform? No need

Re: Internal error mixing templates and CTFE

2017-09-15 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 15 September 2017 at 05:58:47 UTC, David Bennett wrote: Is this an error in dmd, and should I open a bug report? Internal error is always a bug, so it should be reported! Andrea

Re: Internal error mixing templates and CTFE

2017-09-15 Thread David Bennett via Digitalmars-d-learn
On Friday, 15 September 2017 at 07:12:36 UTC, Andrea Fontana wrote: Internal error is always a bug, so it should be reported! I have opened a issue: https://issues.dlang.org/show_bug.cgi?id=17828

Internal error mixing templates and CTFE

2017-09-15 Thread David Bennett via Digitalmars-d-learn
Hi Guys, I've been playing around with CTFE today to see how far I would push it but I'm having an issue appending to an array on a struct in CTFE from a template: ``` struct Content{ string[] parts; } void add_part_to_content(Content content, string s)(){ content.parts ~= "Part:

Re: extern(C) enum

2017-09-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 15, 2017 19:04:56 jmh530 via Digitalmars-d-learn wrote: > On Friday, 15 September 2017 at 18:20:06 UTC, Jonathan M Davis > > wrote: > > It is my understanding that for both C and C++, an enum is > > always an int (unless you're talking about enum classes in > > C++). The size

How to get DnD to work in GTKD?

2017-09-15 Thread Joseph via Digitalmars-d-learn
This is my code: TargetEntry te = new TargetEntry("test", GtkTargetFlags.OTHER_APP, 0); w.dragDestSet(GtkDestDefaults.ALL, [te], GdkDragAction.COPY); w.addOnDragDataReceived((dragContext, x, y, selectionData, info, time, widget) { writeln("ok1"); }); w.addOnDragDrop((dragContext, x, y,

Re: Convert user input string to Regex

2017-09-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 16 September 2017 at 03:18:31 UTC, Ky-Anh Huynh wrote: Is there a way to transform user input string to a regular expression? For example, I want to write a `grep`-like program import std.regex; auto re = regex(user_pattern, user_flags); You'll probably want to split it on the

Convert user input string to Regex

2017-09-15 Thread Ky-Anh Huynh via Digitalmars-d-learn
Hi, Is there a way to transform user input string to a regular expression? For example, I want to write a `grep`-like program ``` mygrep -E '/pattern/i' file.txt ``` and here the user's parameter `/pattern/i` would be converted to a Regex object. Fyi, in Ruby, `to_regexp` is a useful gem:

Re: extern(C) enum

2017-09-15 Thread Timothy Foster via Digitalmars-d-learn
On Friday, 15 September 2017 at 19:35:50 UTC, nkm1 wrote: On Friday, 15 September 2017 at 19:21:02 UTC, Timothy Foster wrote: I believe C enum size is implementation defined. A C compiler can pick the underlying type (1, 2, or 4 bytes, signed or unsigned) that fits the values in the enum.

Binary serialization of a struct

2017-09-15 Thread Joseph via Digitalmars-d-learn
Are there any simple direct serialization libraries where I can mark elements of a class or struct that I want serialized with an attribute and it will take care of all the rest(including recursive structures, arrays, etc) then deserialize back in to the structs? I want something straight

Re: extern(C) enum

2017-09-15 Thread bitwise via Digitalmars-d-learn
On Friday, 15 September 2017 at 19:35:50 UTC, nkm1 wrote: On Friday, 15 September 2017 at 19:21:02 UTC, Timothy Foster wrote: I believe C enum size is implementation defined. A C compiler can pick the underlying type (1, 2, or 4 bytes, signed or unsigned) that fits the values in the enum.

Re: failed loading freetype 2.6 via derelict-ft

2017-09-15 Thread Mike Parker via Digitalmars-d-learn
On Friday, 15 September 2017 at 16:04:52 UTC, Spacen wrote: Thanks for the reply that is exactly it. I downloaded several dlls from the internet, and then decided to build it myself. I see there is a bzip configuration option but I'll need to read the documentation and presumably bzip gets