Re: Debugging bad requests with vibe

2018-02-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote: On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote: Is there a way I can see/log what requests are being made? I can change both the client and server. -v and -vv So it turns out that structs do not work as parameters

Re: Debugging bad requests with vibe

2018-02-09 Thread rjframe via Digitalmars-d-learn
On Fri, 09 Feb 2018 15:48:54 +, Nicholas Wilson wrote: > On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote: >> On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote: >>> Is there a way I can see/log what requests are being made? I can >>> change both the client and server.

Re: Elegant way to use dynamic bindings

2018-02-09 Thread Mike Wey via Digitalmars-d-learn
On 09-02-18 15:04, Dennis wrote: I read the Derelict documentation a while ago, I didn't grasp all of it. Reading it again, I can now make sense of it though. :) On Friday, 9 February 2018 at 12:53:44 UTC, Mike Parker wrote: Did you link with the library you created with implib? That linker

Re: Debugging on Windows

2018-02-09 Thread Benjamin Thaut via Digitalmars-d-learn
On Thursday, 8 February 2018 at 21:09:33 UTC, JN wrote: Hi, is there any way to debug binaries on Windows? I'd at least like to know which line of code made it crash. If it's D code, I get a call trace usually, but if it's a call to a C library, I get a crash and that's it. I am using VSCode

Re: Elegant way to use dynamic bindings

2018-02-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 February 2018 at 14:04:05 UTC, Dennis wrote: I added `pragma(lib, "mupen64plus.lib");` above the extern(C) block. Adding `libs "mupen64plus"` to dub.sdl doesn't make a difference. Where was the lib file located? Was it in the root project directory? How are you compiling your

uint[3] not equivalent to void[12]?

2018-02-09 Thread Ralph Doncaster via Digitalmars-d-learn
This seems odd to me. Is there a way I can make a function that takes an array of any type but only of a specific size in bytes? void.d(8): Error: function void.foo (void[12] arr) is not callable using argument types (uint[3]) Failed: ["/usr/bin/dmd", "-v", "-o-", "void.d", "-I."] void

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 February 2018 at 15:05:33 UTC, Ralph Doncaster wrote: This seems odd to me. Is there a way I can make a function that takes an array of any type but only of a specific size in bytes? void.d(8): Error: function void.foo (void[12] arr) is not callable using argument types

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread Ralph Doncaster via Digitalmars-d-learn
On Friday, 9 February 2018 at 16:28:50 UTC, Nicholas Wilson wrote: On Friday, 9 February 2018 at 15:50:24 UTC, Ralph Doncaster wrote: Is there a way I can make a function that takes an array of any type but only of a specific size in bytes? With a template that constrains the types size:

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 February 2018 at 15:24:27 UTC, Mike Parker wrote: import std.stdio; enum numBytes = 12; void foo(T, size_t N)(T[N] arr) if((N * T.sizeof) == numBytes) { writeln(arr); } void bar(ubyte[12] arr) { writeln(arr); } Also, it's worth mentioning in case you

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Feb 09, 2018 at 03:05:33PM +, Ralph Doncaster via Digitalmars-d-learn wrote: > This seems odd to me. Is there a way I can make a function that takes > an array of any type but only of a specific size in bytes? > > void.d(8): Error: function void.foo (void[12] arr) is not callable >

Re: Elegant way to use dynamic bindings

2018-02-09 Thread Dennis via Digitalmars-d-learn
On Friday, 9 February 2018 at 14:51:30 UTC, Mike Parker wrote: Where was the lib file located? Was it in the root project directory? How are you compiling your project? What does your directory tree look like? (...) That depends. Is that the directory where your executable is written? Are you

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread Ralph Doncaster via Digitalmars-d-learn
On Friday, 9 February 2018 at 15:24:27 UTC, Mike Parker wrote: On Friday, 9 February 2018 at 15:05:33 UTC, Ralph Doncaster wrote: This seems odd to me. Is there a way I can make a function that takes an array of any type but only of a specific size in bytes? void.d(8): Error: function

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 9 February 2018 at 15:50:24 UTC, Ralph Doncaster wrote: On Friday, 9 February 2018 at 15:24:27 UTC, Mike Parker wrote: On Friday, 9 February 2018 at 15:05:33 UTC, Ralph Doncaster wrote: This seems odd to me. Is there a way I can make a function that takes an array of any type but

Re: Elegant way to use dynamic bindings

2018-02-09 Thread Dennis via Digitalmars-d-learn
On Friday, 9 February 2018 at 18:14:06 UTC, Mike Wey wrote: You may need to pass `/s` to implib so it will add the underscore to the symbol in the import library. If it's actually needed depends on what the dll uses. That did it, now both dynamic loading and dynamic linking work. :) Thanks

Error in template instantiation from D-Cookbook example

2018-02-09 Thread ShadoLight via Digitalmars-d-learn
Hi, Trying to improve my CT-fu, I looked at a DSL example (chapter 9) in Adam's D-Cookbook. Although I am sure Adam's original examples would have worked, there were some errors in the example code in the book. The example also contains some code to allow you to test the functions at RT,

Re: Error in template instantiation from D-Cookbook example

2018-02-09 Thread ShadoLight via Digitalmars-d-learn
On Friday, 9 February 2018 at 21:39:22 UTC, Adam D. Ruppe wrote: On Friday, 9 February 2018 at 21:31:29 UTC, ShadoLight wrote: [1] https://run.dlang.io/is/dyElXg There's missing quotes in there: Line 14: code ~= "push(call!"~piece~"(pop(), pop()));\n"; Should be: code ~=

typedef behavior

2018-02-09 Thread Alex via Digitalmars-d-learn
A question about Typedef usage: Say, I have the following circumstances /// --- code --- /// import std.typecons; void main() { MyEA ea; MyEB eb; ea.tarr.length = 5; static assert(!is(MyEA == MyEB)); static assert(!is(MyEA == E)); static

Re: Error in template instantiation from D-Cookbook example

2018-02-09 Thread Meta via Digitalmars-d-learn
On Friday, 9 February 2018 at 21:31:29 UTC, ShadoLight wrote: writeln(parse(code)); // to aid with debugging writeln(convertToD(parse(code))); // debugging aid ..to.. writeln(parse(code)[]); // to aid with debugging

Re: Run-time initialised static variables

2018-02-09 Thread dekevin via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 23:03:07 UTC, dekevin wrote: Hello everyone, I just ran into the problem, that I need a static variable, where the initialisation code for that variable is only accessible during run-time (since part of the initialisation code will be dynamically linked). Is

Re: typedef behavior

2018-02-09 Thread Alex via Digitalmars-d-learn
On Saturday, 10 February 2018 at 01:01:39 UTC, Ali Çehreli wrote: On 02/09/2018 03:45 PM, Alex wrote: > A question about Typedef usage: > Say, I have the following circumstances > > /// --- code --- /// > > import std.typecons; > > void main() > { > MyEA ea; > MyEB eb; >

Re: typedef behavior

2018-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/09/2018 03:45 PM, Alex wrote: > A question about Typedef usage: > Say, I have the following circumstances > > /// --- code --- /// > > import std.typecons; > > void main() > { > MyEA ea; > MyEB eb; > ea.tarr.length = 5; > static assert(!is(MyEA == MyEB)); > static

Re: typedef behavior

2018-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/09/2018 05:14 PM, Alex wrote: >> > struct E >> > { >> > size_t i; >> > static T[] tarr; >> >> To save time to others, note that 'tarr' is a static member that ends >> up being shared by two Typedef instantiations. > > Yup. They are shared by two Typedef instantiations with

Re: typedef behavior

2018-02-09 Thread Alex via Digitalmars-d-learn
On Saturday, 10 February 2018 at 02:08:50 UTC, Alex wrote: Inside of the struct E I define more then one static array. Namely, one for each Typedef I plan to instantiate. The Typedefs have to be known at compile time, so the amount of them has to be known by me :) Then, during the

Re: typedef behavior

2018-02-09 Thread Alex via Digitalmars-d-learn
On Saturday, 10 February 2018 at 01:23:20 UTC, Ali Çehreli wrote: > > Yup. They are shared by two Typedef instantiations with different cookies. > > So... > The question is two-fold: > Would it help to alter the init value of the Typedef? > If yes, how to alter it? > If no, is this a bug? I

opDispatch with string mixin does not work as I would expect.

2018-02-09 Thread German Diago via Digitalmars-d-learn
Hello everyone, I am trying to forward some member functions from a struct as a Catch-all function, so I did something like this: struct A { struct HeaderData { align(1): char [21] id; ubyte field1; ubyte field2; }

Re: opDispatch with string mixin does not work as I would expect.

2018-02-09 Thread Boris-Barboris via Digitalmars-d-learn
On Saturday, 10 February 2018 at 06:32:43 UTC, German Diago wrote: The mixin line does not work. I want to generate the access to the field. How could I achieve that? struct Outer { struct Inner { int a; float b; } Inner i;

Re: opDispatch with string mixin does not work as I would expect.

2018-02-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 10 February 2018 at 06:32:43 UTC, German Diago wrote: Hello everyone, I am trying to forward some member functions from a struct as a Catch-all function, so I did something like this: struct A { struct HeaderData { align(1): char [21] id;

Re: Error in template instantiation from D-Cookbook example

2018-02-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 9 February 2018 at 21:31:29 UTC, ShadoLight wrote: [1] https://run.dlang.io/is/dyElXg There's missing quotes in there: Line 14: code ~= "push(call!"~piece~"(pop(), pop()));\n"; Should be: code ~= "push(call!\""~piece~"\"(pop(), pop()));\n"; That might have been an error in the

Re: Elegant way to use dynamic bindings

2018-02-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 February 2018 at 12:15:04 UTC, Dennis wrote: I found the IMPLIB tool (http://www.digitalmars.com//ctg/implib.html) and made a .lib for the .dll and at first I got: Error 42: Symbol Undefined _CoreGetAPIVersions Error: linker exited with status 1 Forgot to address this in the

Re: Debugging bad requests with vibe

2018-02-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote: On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote: Is there a way I can see/log what requests are being made? I can change both the client and server. -v and -vv All that gives me is a bunch of [FAC3BFF6:FAC451F6 dia]

Re: Debugging bad requests with vibe

2018-02-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 8 February 2018 at 20:24:19 UTC, Nicholas Wilson wrote: On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote: I have set up a vibe.d rest interface (on a server) and have a client on my machine. struct Observation { string desc; DateTime time; } interface

Elegant way to use dynamic bindings

2018-02-09 Thread Dennis via Digitalmars-d-learn
I want to bind to a .dll on Windows, so I looked at how Derelict packages are doing it and found it does it like this: ``` extern(C) { alias da_CoreGetAPIVersions = m64p_error function(int*,int*,int*,int*); ... } __gshared { da_CoreGetAPIVersions CoreGetAPIVersions; ... } protected

Re: Debugging bad requests with vibe

2018-02-09 Thread Arjan via Digitalmars-d-learn
On Friday, 9 February 2018 at 11:46:31 UTC, Nicholas Wilson wrote: On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote: On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote: Is there a way I can see/log what requests are being made? I can change both the client and server.

Re: Elegant way to use dynamic bindings

2018-02-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 February 2018 at 12:15:04 UTC, Dennis wrote: I presume the .dll isn't loaded properly (if at all), but I can't find a load function in the .lib and don't know how to debug this. So I guess I'll just do it manually since that works, but does anyone have some tips to make .dll

Re: Debugging bad requests with vibe

2018-02-09 Thread Seb via Digitalmars-d-learn
On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote: Is there a way I can see/log what requests are being made? I can change both the client and server. -v and -vv

Re: Debugging on Windows

2018-02-09 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 8 February 2018 at 21:09:33 UTC, JN wrote: Hi, is there any way to debug binaries on Windows? I'd at least like to know which line of code made it crash. If it's D code, I get a call trace usually, but if it's a call to a C library, I get a crash and that's it. I am using VSCode

Re: Elegant way to use dynamic bindings

2018-02-09 Thread Dennis via Digitalmars-d-learn
I read the Derelict documentation a while ago, I didn't grasp all of it. Reading it again, I can now make sense of it though. :) On Friday, 9 February 2018 at 12:53:44 UTC, Mike Parker wrote: Did you link with the library you created with implib? That linker error suggests you didn't. I

Re: Debugging bad requests with vibe

2018-02-09 Thread tetyys via Digitalmars-d-learn
On Friday, 9 February 2018 at 11:46:31 UTC, Nicholas Wilson wrote: On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote: On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote: Is there a way I can see/log what requests are being made? I can change both the client and server.