Re: Best way to use large C library in D as of 2024

2024-03-30 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 30 March 2024 at 05:01:32 UTC, harakim wrote: @D Language Foundation - This is a HUGE selling point. I had to use cups the other day and I just copied some code from a d file and linked the library. It was so easy I was suspicious but it worked. Using C from D is pretty much as

Re: DIP 1036e not on the DIPs list?

2024-02-23 Thread Mike Parker via Digitalmars-d-learn
On Friday, 23 February 2024 at 23:30:26 UTC, kdevel wrote: The DIP 1036e is not listed in https://github.com/dlang/DIPs/tree/master/DIPs is this intentional? The DIP process has been closed for a while now. Atila did write a proposal for Adam's implementation, and I'll add it to the repo

Re: pragma lib doesn't support static libraries?

2023-07-29 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 30 July 2023 at 05:28:32 UTC, ryuukk_ wrote: I should have explained exactly what i am doing.. Looks like it doesn't work when i compile in 2 step - compile with: ``dmd -c of=bin/game.o`` - link with: ``dmd bin/game.o`` When doing it this way, then it doesn't work However, when

Re: Designated initializers to function argument

2023-07-28 Thread Mike Parker via Digitalmars-d-learn
On Friday, 28 July 2023 at 21:07:47 UTC, bachmeier wrote: On Friday, 28 July 2023 at 17:07:37 UTC, IchorDev wrote: No shit, it felt like an eternity. But it's still not in the spec...? I'd expect it to appear in the spec after there's a real release. This is the first I've heard of it

Re: GDC Compilation wtih Directory Present

2023-06-16 Thread Mike Parker via Digitalmars-d-learn
On Friday, 16 June 2023 at 06:38:17 UTC, Murloc wrote: Thanks! That works well. I thought that `module pack.file1` is implicitly there by default :') The compiler will use the file name as a default module name if you don't provide one, but that's *just* the module name. It doesn't take

Re: GetInterfaceInfo function of win32 api

2023-06-08 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 8 June 2023 at 07:01:44 UTC, Benny wrote: I got something! thank you. now I need to understand how can I get the properties of the GetInterfaceInfo ``` import core.sys.windows.iphlpapi; import std.stdio; import core.stdc.stdlib; void main() { uint* i; i

Re: GetInterfaceInfo function of win32 api

2023-06-08 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 8 June 2023 at 05:52:43 UTC, Benny wrote: ``` ``` app.obj : error LNK2019: unresolved external symbol GetInterfaceInfo referenced in function _Dmain app.exe : fatal error LNK1120: 1 unresolved externals Error: linker exited with status 1120 ``` That's a linker error telling you

Re: unittest under betterC

2023-06-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 June 2023 at 14:29:35 UTC, Richard (Rikki) Andrew Cattermole wrote: On 06/06/2023 2:25 AM, Mike Parker wrote: On Monday, 5 June 2023 at 14:16:39 UTC, ryuukk_ wrote: In my book this is broken and needs to be fixed, as a user i don't care about under the hood things, it's a you

Re: unittest under betterC

2023-06-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 June 2023 at 14:16:39 UTC, ryuukk_ wrote: In my book this is broken and needs to be fixed, as a user i don't care about under the hood things, it's a you problem, user should be able to unit test The docs say it should work: https://dlang.org/spec/betterc.html#unittests So

Re: How does D’s ‘import’ work?

2023-06-03 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 3 June 2023 at 09:04:35 UTC, Dom DiSc wrote: You can replace your whole makefile by calling the compiler with -I (not always, but if you don't do funny things in your makefile). That would be `-i`. - This ability of the D compiler was just recently discovered (after -I was

Re: How static link dll msvcr120.dll?

2023-06-01 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 1 June 2023 at 15:05:40 UTC, Marcone wrote: I linked msvcr120.lib, but the executable still ask for msvcr120.dll not found. msvcr120.lib is a "link library", not a static library. On other systems, you pass shared libraries directly to the linker and it will pull the

Re: A Programmer's Dilema: juggling with C, BetterC, D, Macros and Cross Compiling, etc.

2023-05-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 1 May 2023 at 09:17:14 UTC, Eric P626 wrote: This is a false dilemma: D has full C compatibility. From what I understand, D can use C, but C cannot use D? It's like C++: C++ can call C but C cannot call C++. 50% or more of my code will be put in re-usabled libraries. If I want

Re: A Programmer's Dilema: juggling with C, BetterC, D, Macros and Cross Compiling, etc.

2023-05-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 1 May 2023 at 09:35:59 UTC, Dukc wrote: hard. Seems the C-linked functions in [core.runtime](https://dlang.org/phobos/core_runtime.html#.Runtime.initialize) ought to do the trick. If you're referring to `rt_init` and `rt_term` are the `extern(C)` functions in `core.runtime`. It's

Re: Making a D library for a C executable

2023-04-27 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 27 April 2023 at 20:32:24 UTC, Jan Allersma wrote: ``` Apparently foo isn't found from the CPP source file. Anyone some ideas on how to solve this? :) That's a compilation error, not a linker problem. You need to tell the compiler about the function with a prototype: ```C++

Re: Cannot get this C++ example migrated to D

2023-04-16 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 16 April 2023 at 07:46:53 UTC, Skippy wrote: I wish D had value type classes as well. I like the distinction between class and struct in D. It encourages you to think harder about how you intend to use your types. In C++, there may as well only be one or the other; the

Re: Cannot get this C++ example migrated to D

2023-04-16 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 16 April 2023 at 05:58:39 UTC, Skippy wrote: These lines aren't necessary: // ?? int counter; // ?? static this() { counter = test.objCnt; } `t1` is default-initialized, so it's null. test t1, t2 = new test(); Ditto for t3. Classes are reference objects, not value

Re: Unresolvable dependencies to package

2023-04-14 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 15 April 2023 at 00:42:17 UTC, Mike Parker wrote: I also suggest you visit the issues page for bindbc-imgui and file an issue there: I meant to delete this line. I've filed the issue: https://github.com/BindBC/bindbc-imgui/issues/1

Re: Unresolvable dependencies to package

2023-04-14 Thread Mike Parker via Digitalmars-d-learn
On Friday, 14 April 2023 at 20:30:56 UTC, el machine code wrote: so my question why am i'm getting this error and how do i fix this? The two listed packages depend on bindbc-sdl, and they do so in a way that is incompatible with each other. On your end, you can edit `dub.selections.json` in

Re: How to setup D with SFML? (using bindbc-sfml)

2023-04-09 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 9 April 2023 at 09:54:26 UTC, Ki Rill wrote: Why can't it find these libraries? I tell where to look for them: ```D version(Windows) { import bindbc.loader; setCustomLoaderSearchPath("libs"); // tried using absolute path as well } ``` That is strange... I've tried

Re: How to setup D with SFML? (using bindbc-sfml)

2023-04-08 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 8 April 2023 at 11:31:40 UTC, Ki Rill wrote: How do I set up a D and SFML project using the `bindbc-sfml` package? I tried following the instructions, it builds successfully, but fails to load the SFML library at runtime. In particular, `loadSFML, loadSFMLGraphics, loadSFMLXXX`

Re: #define-like behavior

2023-03-14 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 14 March 2023 at 05:47:35 UTC, Jeremy wrote: Hi, in C and C++ you can use #define to substitute a value in place of an identifier while preprocessing. If you initialize a new string and don't change its value after that, will the compiler substitute the string identifier with its

Re: Code organization, dub, etc.

2023-03-13 Thread Mike Parker via Digitalmars-d-learn
On Monday, 13 March 2023 at 13:20:21 UTC, Joe wrote: Yeah, it seems like it's *only* for libraries (and a few single-exe utilities). Looking at code.dlang.org, under "Stand-alone applications/Server software", the top rated item is "handy-httpd" which according to its dub.json builds a

Re: Directly compiling a D program with other libraries

2023-03-13 Thread Mike Parker via Digitalmars-d-learn
On Monday, 13 March 2023 at 05:05:27 UTC, Jeremy wrote: Hello, I am new to this forum and to D. I am trying to compile a basic D program with libraries (`requests` which requires `cachetools` and `automem`) without using dub. I have never used dub before, only a compiler. The folders

Re: @nogc and Phobos

2023-03-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 March 2023 at 12:04:25 UTC, bomat wrote: So my question is: Is Phobos essentially incompatible to `@nogc`? Or is there a trick for mixing GC code with non-GC code that I don't know? I'm assuming the second, for if the first was true I'd say that D would be pretty much

Re: How to build a static lib properly?

2023-03-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 6 March 2023 at 02:09:23 UTC, ryuukk_ wrote: dub should build a static library for the project i build, that includes each library it uses that are referenced as "library" since the default is "staticLibrary" according to rikki What you're asking for is a different use case.

Re: How to build a static lib properly?

2023-03-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 6 March 2023 at 01:52:06 UTC, ryuukk_ wrote: 6B71D90\dparse.lib -g ``` Are you saying dub doesn't build a static dcd.lib? What to do to make it so i get a static dcd.lib file that contains all the code it needs? This comfort me in my desire to no longer use dub ever This is

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-19 Thread Mike Parker via Digitalmars-d-learn
On Monday, 20 February 2023 at 06:26:34 UTC, FeepingCreature wrote: There have now been three pages produced by three people all agreeing with each other. At what point does it start being spam? Yes, it's all just noise now. Let's end it here. Further posts in this thread will be

Re: Dub is not finding the dynamic link library MSVCR120.dll...

2023-02-19 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 19 February 2023 at 21:05:33 UTC, WhatMeWorry wrote: and is abending with an error saying exactly this. How do I specify the path to this library? Can I use one of the environment variables in sc.ini, one of the Windows env variables, or one of the dub options? Btw, I'm

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 16 February 2023 at 02:26:44 UTC, Mike Parker wrote: Wrong. I'm arguing things: Geez. "I'm arguing 2 things:"

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 20:10:31 UTC, ProtectAndHide wrote: What Mike is arguing, is that I don't need a 'data hiding' mechanism for a user-defined type, because that is already provided to me by the 'data hiding' mechanism of the module. That is his argument. My argument is

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 09:51:41 UTC, zjh wrote: What if two classes in the module that are several meters apart make `mistakes` that change the privite variable of `another class`? No one can guarantee that after `a few months`, even if you are the author, you will not make

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 08:56:00 UTC, Mike Parker wrote: If private were restricted to the class/struct, it would add anything more for encapsulation in D. I meant to say, it "wouldn't add more".

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 07:23:39 UTC, thebluepandabear wrote: Why is the unit of encapsulation the module though? Makes no sense. What is the purpose of encapsulation? To keep the implementation details hidden behind the public API, such that changing the implementation doesn't

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-14 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 01:16:00 UTC, thebluepandabear wrote: I think what you could say is that D lacks _encapsulation_ which is also an OOP concept. So D is partially OOP but not fully OOP due to there being no encapsulation in the language. D does not lack encapsulation, it's

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-01-22 Thread Mike Parker via Digitalmars-d-learn
On Monday, 23 January 2023 at 00:36:36 UTC, thebluepandabear wrote: I haven't been programming for a long time, but most of the other languages I used had such a namespace feature. Kotlin has something called an `object` which is essentially a namespace and it is great. The benefits of

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-01-22 Thread Mike Parker via Digitalmars-d-learn
On Monday, 23 January 2023 at 00:11:17 UTC, thebluepandabear wrote: Sorry don't like that solution specifically. That's because it is a procedural implementation, not an OOP-style one. I don't know how much of the D community writes procedurally but I'm personally an OOP-type of guy. A

Re: (Noob question) Should subclasses be defined in separate modules?

2023-01-12 Thread Mike Parker via Digitalmars-d-learn
On Friday, 13 January 2023 at 05:17:59 UTC, thebluepandabear wrote: (Sorry if this is a duplicate.) If I have the following code inside of a module: ```D class Obj { private { string name = "Hi"; } } class ObjDerived : Obj { } ``` Is it best practice to define `ObjDerived`

Re: Compile time vs run time -- what is the difference?

2022-12-27 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 28 December 2022 at 02:31:45 UTC, thebluepandabear wrote: In Java and some other languages, during compile time the code gets executed into Java bytecode. This also happens for C#. I don't know if there is an equivalent 'intermediate' language for D that your code gets

Re: Is there such concept of a list in D?

2022-12-19 Thread Mike Parker via Digitalmars-d-learn
On Monday, 19 December 2022 at 22:22:11 UTC, thebluepandabear wrote: No worries, hopefully a mod will explain why. I don't like when posts get removed for no reason :| I received a report of a possible troll in the forums. Looking at the posts collectively, I agreed, so deleted all of them.

Re: Is defining get/set methods for every field overkill?

2022-11-23 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 24 November 2022 at 03:49:16 UTC, []() {}() wrote: I broke a forum rule by critically analysing your blog? Wow. Criticize my blog posts all you want. Just stop please stop derailing threads. I'm going to delete further off topic posts in this thread.

Re: Is defining get/set methods for every field overkill?

2022-11-23 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 23 November 2022 at 23:35:59 UTC, thebluepandabear wrote: Please stop, we get it... I'm not a moderator so I cannot enforce rules but there is NO need to continue this debate here. This software 'religiousness' is too much. I am a moderator and I can enforce the rules. So

Re: Actual lifetime of static array slices?

2022-11-14 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 15 November 2022 at 02:49:55 UTC, Mike Parker wrote: It's not the scope that matters here. It's the stack. Memory allocated in the inner scope uses the function stack, so it's all valid until the function exits. And that was just so, so wrong. Of course destructors get called

Re: Actual lifetime of static array slices?

2022-11-14 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 15 November 2022 at 02:26:41 UTC, Elfstone wrote: I failed to find any documentation, except dynamic array slices will be taken care of by GC, but I assume it's not the case with static arrays. A slice is a view on the existing memory owned by the original array. No allocations

Re: Using glibc headers with ImportC

2022-11-13 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 13 November 2022 at 09:15:39 UTC, qua wrote: I agree it was unexpected that it didn't, at least for newcomers. Almost everyone is a newcomer when it comes to ImportC.

Re: ImportC linking issue

2022-11-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 November 2022 at 10:02:12 UTC, confuzzled wrote: On Saturday, 12 November 2022 at 08:43:13 UTC, Mike Parker wrote: On Saturday, 12 November 2022 at 02:45:52 UTC, confuzzled wrote: The linker doesn't care if the libraries are C or D, and the compiler is only involved in that

Re: ImportC linking issue

2022-11-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 November 2022 at 02:45:52 UTC, confuzzled wrote: It seems that every time I resolve one of these undefined symbols issues, the compiler finds more. So I keep copying lib files from locations that are a path, to my working directory and linking them to my script. Is that the

Re: dmd as a library

2022-11-07 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 8 November 2022 at 06:21:11 UTC, vushu wrote: So I do feel, that I am in need for some learning materials or guidance. You might find Lucian Danescu's DConf '22 presentation helpful: https://youtu.be/JYkb3PjIn4c

Re: What's the correct way of creating an instance of class in D?

2022-11-03 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 November 2022 at 06:02:13 UTC, Mike Parker wrote: are in C++. D enforces the distinction that C++ ...that C++ programmers often follow by convention.

Re: What's the correct way of creating an instance of class in D?

2022-11-03 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 November 2022 at 05:41:06 UTC, Siarhei Siamashka wrote: Thanks for the link and also thanks for confirming that you have no clue what's going on. I think that what actually That's not necessary. He does know what's going on and pointed you to the correct place. The second

Re: Importing modules under DUB on Windows

2022-10-27 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 27 October 2022 at 16:40:20 UTC, DLearner wrote: I'm not getting on with DUB. Maybe fewer people use it under Windows, so Windows constructs don't get exercised so much. Is there a non-DUB way of arranging that `import arsd.terminal;` will use that module as held on GitHub?

Re: dub ldc2 static linking

2022-10-27 Thread Mike Parker via Digitalmars-d-learn
On Friday, 28 October 2022 at 01:37:50 UTC, Mike Parker wrote: This has nothing to do with dub and is not a D issue specifically. Enter your error message in Google and you'll get a long list of results. Maybe one of them can help you. Or do what kinke suggests :-)

Re: dub ldc2 static linking

2022-10-27 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 27 October 2022 at 08:08:38 UTC, Yura wrote: curl.d:(.text._D3std3net4curl7CurlAPI7loadAPIFZPv+0xd): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking and many other warnings like this.

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-18 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 19 October 2022 at 03:10:29 UTC, Mike Parker wrote: It's right there in the summary of the Final Review of the DIP that I linked above: https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1038.md#final-review I meant to say the summary of the formal assessment. One of

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-18 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 19 October 2022 at 01:34:54 UTC, mw wrote: On Wednesday, 19 October 2022 at 01:30:23 UTC, H. S. Teoh wrote: On Wed, Oct 19, 2022 at 01:15:37AM +, Adam D Ruppe via it only applies to types, not to functions. Wat... so what's the use of it then? So it's not possible to

Re: How do I correctly install packages for use with Visual Studio?

2022-10-16 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 16 October 2022 at 11:09:31 UTC, Decabytes wrote: I'm confused at what/where exactly D expect files to be for them to considered "installed". D doesn't expect them to be anywhere. By default, the compiler will search relative to the current working directory, on any paths

Re: How do I correctly install packages for use with Visual Studio?

2022-10-16 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 16 October 2022 at 11:09:31 UTC, Decabytes wrote: Building x64\Debug\chip8.exe... chip8.d(4): Error: unable to read module `raylib` chip8.d(4):Expected 'raylib.d' or 'raylib\package.d' in one of the following import paths: import path[0] =

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-14 Thread Mike Parker via Digitalmars-d-learn
On Friday, 14 October 2022 at 22:17:52 UTC, H. S. Teoh wrote: Given that this particular trap crops up regularly, perhaps some sort of warning ought to be added. Once the @nodiscard DIP is accepted & implemented this should be easy to do. Seems like you're behind the times! The DIP was

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-14 Thread Mike Parker via Digitalmars-d-learn
On Friday, 14 October 2022 at 21:51:54 UTC, WhatMeWorry wrote: I lost about a half an hour troubleshooting some code of mine which as it turned out to be resolved with just one line. // paths.remove(i); // compiles fine but does nothing paths = paths.remove(i); // works - what I

Re: Visual D doesn't work, now Visual Studio Code / D doesn't work!!!! ....

2022-10-02 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 2 October 2022 at 11:00:06 UTC, Daniel Donnell, Jr wrote: I thought I set everything up correctly, and now: ``` Exception thrown at 0x7FF7D6E2E230 in metamath-d.exe: 0xC096: Privileged instruction. Unable to open natvis file

Re: D installer

2022-10-02 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 2 October 2022 at 11:33:47 UTC, Imperatorn wrote: I only have Visual Studio 2022. Will the installer be updated to support that or am I missing some components? ![Installer](https://i.ibb.co/sCZRFRf/installer.jpg) You should be fine. Select the bottom option since you already

Re: Why I get delegate when passing address of function?

2022-09-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 11 September 2022 at 09:15:11 UTC, Mike Parker wrote: Pointers to non-static member functions always produce a delegate. Otherwise, you wouldn't be able to access the class instance's members. Reference: https://dlang.org/spec/function.html#closures

Re: Why I get delegate when passing address of function?

2022-09-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 11 September 2022 at 09:02:31 UTC, Injeckt wrote: I have a one class and two modificators, where in "public" function I'm calling CreateThread with address of the ClientThread function which stored in same class, but in "private" modificator. And i get this error: Error: cannot

Re: How I can pass the WndProc as a parameter?

2022-09-10 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 10 September 2022 at 10:39:12 UTC, Injeckt wrote: To elaborate on why you need the above... But I get these bugs: WndProc is a function, and you can't pass a function as a runtime function parameter, only pointers to functions. The first two errors tell you exactly what the

Re: How I can pass the WndProc as a parameter?

2022-09-10 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 10 September 2022 at 10:39:12 UTC, Injeckt wrote: And after all, I call it: KK_CreateWindowClass(WndProc); `KK_CreateWindowClass();`

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 = ...;

Re: How to link a msvcr120.dll in an inverse recursive way after a Windows .exe binary deployment

2022-09-05 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 6 September 2022 at 04:36:55 UTC, ShadoLight wrote: True. In that case just distribute the DLL (taken from the DMD bin folder) alongside the HelloWorld EXE so that both reside in the same folder on the target computer. The proper way to do this is to ship the correct version of

Re: This code completely breaks the compiler:

2022-08-18 Thread Mike Parker via Digitalmars-d-learn
On Friday, 19 August 2022 at 04:25:25 UTC, Ruby The Roobster wrote: So that's why it compiled. Still, I believe that stuff like this ought to be detected at compile time, as supposed to in a unittest or, if someone forgot to write the tests, in production. If the template is never

Re: char* pointers between C and D

2022-07-25 Thread Mike Parker via Digitalmars-d-learn
On Monday, 25 July 2022 at 09:04:29 UTC, pascal111 wrote: I have small C program that uses a pointer to change the start address of a string, and when I tried to do the same code but with D, the D code printed the address of the string after I increased it one step instead of printing the

Re: dlang bug - accessing module variable from method segfaults only when using module reference directly

2022-07-01 Thread Mike Parker via Digitalmars-d-learn
On Friday, 1 July 2022 at 13:44:20 UTC, Chris Katko wrote: It appears module access to a class is broken until the constructor finishes. No, it has nothing to do with the module. It's the reference itself. Until the constructor returns, the reference through which you're constructing the

Re: dlang bug - accessing module variable from method segfaults only when using module reference directly

2022-07-01 Thread Mike Parker via Digitalmars-d-learn
On Friday, 1 July 2022 at 13:20:15 UTC, Mike Parker wrote: r. And that also looks like the source of your original segfault. You've got a circular reference going on in the constructors. In other words, you're constructing a global world instance, which in turn constructs an elf instance,

Re: dlang bug - accessing module variable from method segfaults only when using module reference directly

2022-07-01 Thread Mike Parker via Digitalmars-d-learn
On Friday, 1 July 2022 at 13:01:30 UTC, Chris Katko wrote: Forgot the last line. That's important because world MUST exist by time elf is called... because world... created and called elf. So it's not a memory issue, but some sort of linkage issue. world is null because the constructor

Re: Static Initialization of Structs syntax

2022-06-22 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 22 June 2022 at 11:19:59 UTC, Antonio wrote: I see now: DIP 1033 will solve this (i.e., using named arguments in struct constructor... similar to how dart/flutter works) That would be DIP 1030: https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1030.md Max

Re: Convering strings containing number

2022-06-14 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 June 2022 at 04:26:44 UTC, Salih Dincer wrote: Hi, I've been interested in conversion possibilities for a while. I tried to convert a string containing numbers but with no success in single digits. The only solution I found is to subtract 48 from the result: ```d import

Re: ImportC: unresolved external symbol

2022-06-14 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 14:32:50 UTC, ryuukk_ wrote: ``` nk.obj : error LNK2019: unresolved external symbol test referenced in function _Dmain ``` Am i missing something important? (that is a dub project, created with: dub init) DMD: v2.100.0-dirty This works from the command line:

Re: Can I create a package with friendly modules

2022-06-12 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 12 June 2022 at 23:29:29 UTC, forkit wrote: I don't get it. How does this enable one module to access the private parts of another module? It doesn't. But what you were describing in your post is package-level access. By keeping it the cross-module access in a subpackage,

Re: Can I create a package with friendly modules

2022-06-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 12 June 2022 at 05:05:46 UTC, forkit wrote: Is it possible to create a package.d, consisting of (for example), two modules, where each module can access private declarations within each other. In essence, declaring 'a module level friendship', or a kind of 'extended module' if you

Re: Why allow initializers of non-static members that allocate?

2022-06-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 June 2022 at 10:37:30 UTC, Bastiaan Veelo wrote: So that’s why I used “why” in the title of this thread, which I haven’t seen an answer to yet. What is the practical case where that warning would be annoying? When would you actually want this behaviour? After actually

Re: Why allow initializers of non-static members that allocate?

2022-06-10 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 June 2022 at 01:14:06 UTC, matheus wrote: So, in the case of "int[] arr = new int[](5)", an array of length 5 of type int will be instantiated and its address will be shared among whoever instantiates "S" and be pointed and accessed through arr. In the second case, "int[2]

Re: Why allow initializers of non-static members that allocate?

2022-06-10 Thread Mike Parker via Digitalmars-d-learn
On Friday, 10 June 2022 at 14:56:24 UTC, Steven Schveighoffer wrote: Discovered circa 2009: https://issues.dlang.org/show_bug.cgi?id=2947 It should be illegal to declare a field this way that has mutable references without being `shared`. End of story. -Steve The docs do say that: The

Re: Why allow initializers of non-static members that allocate?

2022-06-10 Thread Mike Parker via Digitalmars-d-learn
On Friday, 10 June 2022 at 07:46:36 UTC, Mike Parker wrote: I think this is a case where having a warning that's on by default, and which can be explicitly disabled, is useful. "Blah blah .init blah blah. See link-to-something-in-docs. Is this what you intended?" And it *is* documented:

Re: Why allow initializers of non-static members that allocate?

2022-06-10 Thread Mike Parker via Digitalmars-d-learn
On Friday, 10 June 2022 at 07:35:17 UTC, Bastiaan Veelo wrote: Is there a use case where this makes sense? I would have much appreciated the compiler slapping me on the fingers, but it doesn't. I understand that it is safe and that the compiler can allow this, but why would anyone want that?

Re: C-like static array size inference - how?

2022-06-07 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 8 June 2022 at 00:43:24 UTC, Ali Çehreli wrote: Do I remember correctly that there were syntax proposals that used $ or _? int[$] arr = [ 1, 2 ]; int[_] arr = [ 1, 2 ]; But I can't find past discussions about that.

Re: dlang compilers & licenses.

2022-06-04 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 4 June 2022 at 14:13:08 UTC, Alain De Vos wrote: Do DMD , GDC , LDC have the same or different licenses in use ? DMD https://github.com/dlang/dmd/blob/master/LICENSE.txt LDC https://github.com/ldc-developers/ldc/blob/master/LICENSE GDC

Re: Dynamic Arrays Capacity

2022-06-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 2 June 2022 at 08:24:51 UTC, Mike Parker wrote: And so, `[0]` is the same as `&(*ts.ptr + 0)`, or simply `ts.ptr`. That should be the same as `&(*(ts.ptr + 0))`!

Re: Dynamic Arrays Capacity

2022-06-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 2 June 2022 at 08:14:40 UTC, Mike Parker wrote: More specifically, it points to the starting address of the allocated block of memory. I posted too soon. Given an instance `ts` of type `T[]`, array accesses essentially are this: ```d ts[0] == *(ts.ptr + 0); ts[1] == *(ts.ptr +

Re: Dynamic Arrays Capacity

2022-06-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 2 June 2022 at 05:04:03 UTC, Salih Dincer wrote: Hi, Do I misunderstand? A dynamic array is allocated memory according to the `nextpow2()` algorithm(-1 lapse); strings, on the other hand, don't behave like this... ```d string str = "0123456789ABCDEF"; char[] chr = str.dup;

Re: Odd construct idea. Splitting arguments inside a parameter list.

2022-05-23 Thread Mike Parker via Digitalmars-d-learn
On Monday, 23 May 2022 at 08:34:21 UTC, Chris Katko wrote: D I'm curious if you can pass a struct of values (a 'tuple'?) with the right subfields, as if those fields occupied a function signature. (As I write this and try to explain it, it probably sounds impossible.) Right now you

Re: template? mixin? template mixins? for modifying a struct setup

2022-05-20 Thread Mike Parker via Digitalmars-d-learn
On Friday, 20 May 2022 at 14:54:31 UTC, Christopher Katko wrote: So wait, that means if I have a module with extra stuff like D colors.d auto red = // grey and then in my other file D auto white = grey(1.0); It won't use CTFE? Why is there a local module requirement? I'm

Re: UI Library

2022-05-20 Thread Mike Parker via Digitalmars-d-learn
On Friday, 20 May 2022 at 07:05:21 UTC, Tejas wrote: Maybe gtkd? https://code.dlang.org/packages/gtk-d And some corresponding tutorials: https://gtkdcoding.com/

Re: template? mixin? template mixins? for modifying a struct setup

2022-05-19 Thread Mike Parker via Digitalmars-d-learn
On Friday, 20 May 2022 at 00:12:44 UTC, Chris Katko wrote: Yeah that occurred to me as I was falling asleep. Though, do I have to a specify ```D static auto myColor = grey(0.5); ``` to ensure it's done at compile time? It's not the end of the world, but ideally, these are static / hardcoded

Re: Question on shapes

2022-05-17 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 05:08:30 UTC, matheus wrote: In D there would be a better way to do such thing? Nothing really specific to D, but for one or two properties, you might just add them as function parameters with default values: ```d void draw(float scale = 1.0f); ``` If you have

Re: Why are structs and classes so different?

2022-05-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 15 May 2022 at 20:05:05 UTC, Kevin Bailey wrote: One question is, how should we pass objects - by value or by reference? In C++, you can do either, of course, but you take your chances if you pass by value - both in safety AND PERFORMANCE. The bottom line is that no one passes by

Re: Why are structs and classes so different?

2022-05-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 15 May 2022 at 15:26:40 UTC, Kevin Bailey wrote: I'm trying to understand why it is this way. I assume that there's some benefit for designing it this way. I'm hoping that it's not simply accidental, historical or easier for the compiler writer. There's a problem that arises with

Re: Parameters of overloaded templated function

2022-05-10 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 12:12:13 UTC, Tejas wrote: Using aliases as parameters doesn't work(and the DIP that wanted to have this behaviour was de facto rejected) https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1023.md No, it wasn't rejected. The author decided it needed

Re: How to convert a LPCWSTR aka const(wchar)* to string

2022-05-09 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 00:50:09 UTC, Vinod K Chandran wrote: I want to convert this `pszUserString` to a string. How to do it. Thanks in advance. ```d import std.conv : to; string s = to!string(pszUserString); ```

Re: How to use destroy and free.

2022-05-04 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 4 May 2022 at 05:37:49 UTC, forkit wrote: That's not at all what I said. You don't have to care about *when* memory is deallocated, meaning you don't have to manage it yourself. In any case, I disagree that caring about when memory gets deallocted means you shouldn't be using

Re: How to use destroy and free.

2022-05-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 4 May 2022 at 04:52:05 UTC, forkit wrote: It is certainly *not* about you not having to care anymore (about memory management). That's not at all what I said. You don't have to care about *when* memory is deallocated, meaning you don't have to manage it yourself.

Re: How to use destroy and free.

2022-05-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 14:57:46 UTC, Alain De Vos wrote: Note, It's not i'm against GC. But my preference is to use builtin types and libraries if possible, But at the same time be able to be sure memory is given free when a variable is going out of scope. It seems not easy to combine the

Re: How to use destroy and free.

2022-05-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 12:59:31 UTC, Alain De Vos wrote: Error: array literal in @nogc function test.myfun may cause a GC allocation @nogc void myfun(){ scope int[] i=[1,2,3]; }//myfun May is a fuzzy word... It means if the compiler is free to allocate on the stack if possible.

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 2 May 2022 at 00:54:40 UTC, Elfstone wrote: Thanks. This breaks a lot of things. I don't know the reason behind the postponing, but who would expect one can't declare a parameter with an alias if it's a template?! Speaking of inconsistency. At the bottom of the DIP you can find a

  1   2   3   4   5   6   7   8   9   10   >