Storing a lambda alongside type-erased data

2022-09-07 Thread Ali Çehreli via Digitalmars-d-learn
I am sure nothing is new here and I may have thought of this before but it was a revelation today. :) I've been trying to come up with a way of storing arbitrary number of objects of arbitrary types, which means I would be using a ubyte array. But then how do I use the data later without

Re: Error "Unexpected '\n' when converting from type LockingTextReader to type int"

2022-09-07 Thread Ali Çehreli via Digitalmars-d-learn
On 9/7/22 16:24, Synopsis wrote: > a- What is the difference with this syntax with the exclamation mark? > ```readf!"%s\n"(f1.num);``` That's the templated version, which is safer because it checks at compile time (important distinction) that the arguments and the format specifiers do match.

Re: Error "Unexpected '\n' when converting from type LockingTextReader to type int"

2022-09-07 Thread rikki cattermole via Digitalmars-d-learn
On 08/09/2022 11:24 AM, Synopsis wrote: On Wednesday, 7 September 2022 at 23:06:44 UTC, rikki cattermole wrote: Text in buffer: "123\n" Read: "123" Text in buffer: "\n" Read: exception, expecting number for "\n" Changing your readf format specifier to include the new line should work.

Re: Error "Unexpected '\n' when converting from type LockingTextReader to type int"

2022-09-07 Thread Synopsis via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 23:06:44 UTC, rikki cattermole wrote: Text in buffer: "123\n" Read: "123" Text in buffer: "\n" Read: exception, expecting number for "\n" Changing your readf format specifier to include the new line should work.

Re: Error "Unexpected '\n' when converting from type LockingTextReader to type int"

2022-09-07 Thread rikki cattermole via Digitalmars-d-learn
Text in buffer: "123\n" Read: "123" Text in buffer: "\n" Read: exception, expecting number for "\n" Changing your readf format specifier to include the new line should work. https://dlang.org/phobos/std_stdio.html#.File.readf

Re: How include header file?

2022-09-07 Thread Injeckt via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 23:01:34 UTC, Mike Parker wrote: On Wednesday, 7 September 2022 at 20:23:03 UTC, Injeckt wrote: Convert it to D: extern(C) const(char)* inet_ntop(int af, const(void)* src, char* dst, socklen_t size); Win32 API functions need to be `extern(Windows)`.

Re: How include header file?

2022-09-07 Thread Injeckt via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 22:57:53 UTC, Loara wrote: On Wednesday, 7 September 2022 at 20:23:03 UTC, Injeckt wrote: On Wednesday, 7 September 2022 at 19:38:52 UTC, H. S. Teoh wrote: On Wed, Sep 07, 2022 at 06:11:14PM +, Injeckt via Digitalmars-d-learn wrote: You need to link

Re: How include header file?

2022-09-07 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 20:23:03 UTC, Injeckt wrote: Convert it to D: extern(C) const(char)* inet_ntop(int af, const(void)* src, char* dst, socklen_t size); Win32 API functions need to be `extern(Windows)`. You probably also need: alias socklen_t = ...;

Error "Unexpected '\n' when converting from type LockingTextReader to type int"

2022-09-07 Thread Synopsis via Digitalmars-d-learn
Hi! I'm new at programming, just discovered D and I'm loving it so far! I'm learning the basics, so please forgive my noob mistakes and questions (as well as my Engrish...). I'm trying to make this program print both numbers entered by the user, it works with the first number (num): ```d

Re: How include header file?

2022-09-07 Thread Loara via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 20:23:03 UTC, Injeckt wrote: On Wednesday, 7 September 2022 at 19:38:52 UTC, H. S. Teoh wrote: On Wed, Sep 07, 2022 at 06:11:14PM +, Injeckt via Digitalmars-d-learn wrote: I need to include this Ws2tcpip.h header file to my project. How can I do this? It's

Re: How include header file?

2022-09-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/7/22 4:23 PM, Injeckt wrote: On Wednesday, 7 September 2022 at 19:38:52 UTC, H. S. Teoh wrote: On Wed, Sep 07, 2022 at 06:11:14PM +, Injeckt via Digitalmars-d-learn wrote: I need to include this Ws2tcpip.h header file to my project. How can I do this? It's all because I need inet_ntop

Re: How include header file?

2022-09-07 Thread Injeckt via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 20:23:03 UTC, Injeckt wrote: _inet_ntop". I guess I can add my utils.c to my .d project when I compile project and I need write in this file function wrapper of inet_ntop. No, it doesn't work. Jesus I need to figure out how to add WS2tcpip.h

Re: How include header file?

2022-09-07 Thread Injeckt via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 19:38:52 UTC, H. S. Teoh wrote: On Wed, Sep 07, 2022 at 06:11:14PM +, Injeckt via Digitalmars-d-learn wrote: I need to include this Ws2tcpip.h header file to my project. How can I do this? It's all because I need inet_ntop function from this header file.

Re: How include header file?

2022-09-07 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Sep 07, 2022 at 06:11:14PM +, Injeckt via Digitalmars-d-learn wrote: > I need to include this Ws2tcpip.h header file to my project. How can I > do this? It's all because I need inet_ntop function from this header > file. If that's the only function you need, you can just copy the

How include header file?

2022-09-07 Thread Injeckt via Digitalmars-d-learn
I need to include this Ws2tcpip.h header file to my project. How can I do this? It's all because I need inet_ntop function from this header file.

Re: Reference to an unresolved external symbol

2022-09-07 Thread Injeckt via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 10:50:17 UTC, Dennis wrote: On Wednesday, 7 September 2022 at 10:14:22 UTC, Injeckt wrote: I guess you right. But I don't know how i gonna link libs when I'm using "dmd main.d". Another way is to add this to your code: ```D pragma(lib, "User32"); ``` Oh

Re: Reference to an unresolved external symbol

2022-09-07 Thread Dennis via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 10:14:22 UTC, Injeckt wrote: I guess you right. But I don't know how i gonna link libs when I'm using "dmd main.d". Another way is to add this to your code: ```D pragma(lib, "User32"); ```

Re: Reference to an unresolved external symbol

2022-09-07 Thread Injeckt via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 10:31:02 UTC, rikki cattermole wrote: On 07/09/2022 10:14 PM, Injeckt wrote: On Wednesday, 7 September 2022 at 10:01:11 UTC, rikki cattermole wrote: You have probably forgotten to link against user32. I guess you right. But I don't know how i gonna link

Re: Reference to an unresolved external symbol

2022-09-07 Thread rikki cattermole via Digitalmars-d-learn
On 07/09/2022 10:14 PM, Injeckt wrote: On Wednesday, 7 September 2022 at 10:01:11 UTC, rikki cattermole wrote: You have probably forgotten to link against user32. I guess you right. But I don't know how i gonna link libs when I'm using "dmd main.d". Tell me please. I think it is as

Re: importC and cmake

2022-09-07 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 00:31:53 UTC, zjh wrote: On Tuesday, 6 September 2022 at 19:44:23 UTC, jmh530 wrote: . `xmake` is simpler. Ok...but I didn't write the library so I can't exactly tell them to use xmake when they already use cmake.

Re: Reference to an unresolved external symbol

2022-09-07 Thread Injeckt via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 10:01:11 UTC, rikki cattermole wrote: You have probably forgotten to link against user32. I guess you right. But I don't know how i gonna link libs when I'm using "dmd main.d". Tell me please.

Re: Comparing slices with std.variant.Algebraic

2022-09-07 Thread anonymouse via Digitalmars-d-learn
Thanks Paul. Gotta wrap my head around this well enough to update that module. However, this is a great start. Thank you very much. --anonymouse

Re: Reference to an unresolved external symbol

2022-09-07 Thread rikki cattermole via Digitalmars-d-learn
You have probably forgotten to link against user32.

Reference to an unresolved external symbol

2022-09-07 Thread Injeckt via Digitalmars-d-learn
Hi guys, I have an issue when I compile program with using windows api, I got this message: "reference to an unresolved external symbol _MessageBoxW@16". I just created simple hello world using winapi and MessageBox. import core.runtime; import std.stdio; import std.string;

Re: Best practice for dub registry package and module names

2022-09-07 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 4 September 2022 at 01:52:11 UTC, Ali Çehreli wrote: Let's say I have three modules that work together, which I want to register on dub: A, B, and C. Here I would take inspiration from the Java world, where a "domain" is used per project. Typically this domain is written from