Re: Window created with Windows API is not visible

2022-06-18 Thread Adam Ruppe via Digitalmars-d-learn
On Saturday, 18 June 2022 at 23:00:36 UTC, solidstate1991 wrote: This is going to be a long match. you might consider using another exisitng lib. my simpledisplay.d does all this and much more for example

Re: Comparing Exceptions and Errors

2022-06-04 Thread Adam Ruppe via Digitalmars-d-learn
On Saturday, 4 June 2022 at 22:31:38 UTC, Ola Fosheim Grøstad wrote: So what do you have to do to avoid having Errors thrown? How do you make your task/handler fault tolerant in 100% @safe code? Run it in a separate process with minimum shared memory.

Re: What happened to Deimos and why ?

2022-06-04 Thread Adam Ruppe via Digitalmars-d-learn
On Saturday, 4 June 2022 at 13:44:06 UTC, Alain De Vos wrote: What happened to Deimos and why ? Nothing, it does its job same as it always has.

Re: How to fix "typesafe variadic function parameter"?

2022-05-24 Thread Adam Ruppe via Digitalmars-d-learn
On Tuesday, 24 May 2022 at 22:46:55 UTC, Andrey Zherikov wrote: return S(s); return S(s.dup); The variadic lives in a temporary array that expires at the end of the function. So copying it out to the GC lets it live on. Your code was wrong on 2.099 too, but the compiler didn't tell

Re: Cannot check function address

2022-05-24 Thread Adam Ruppe via Digitalmars-d-learn
On Tuesday, 24 May 2022 at 18:54:33 UTC, frame wrote: Usually that works fine as shown in module A but for some reason not in module B. Do you have some other definition of fun somewhere?

Re: How to call destroy() in @nogc?

2022-05-24 Thread Adam Ruppe via Digitalmars-d-learn
On Tuesday, 24 May 2022 at 14:11:57 UTC, Steven Schveighoffer wrote: Note it has no idea what the real object type is at this point, just that it is an Object (which does not have a @nogc destructor). It actually has nothing to do with Object. It doesn't have a destructor at all, so there's n

Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Adam Ruppe via Digitalmars-d-learn
On Thursday, 19 May 2022 at 21:41:50 UTC, Marcone wrote: Are you using the `-L/entry:mainCRTStartup` or the `L/entry:wmainCRTStartup` ? -L/entry:mainCRTStartup try the w one too. both doing the same result?

Re: Library for image editing and text insertion

2022-04-26 Thread Adam Ruppe via Digitalmars-d-learn
On Tuesday, 26 April 2022 at 18:31:49 UTC, H. S. Teoh wrote: maybe look at Adam Ruppe's arsd library (https://github.com/adamdruppe/arsd) for some lightweight modules that read common image formats and do some primitive image manipulations. I don't actually have an image to image blit functio

Re: A template construct like using()

2022-04-26 Thread Adam Ruppe via Digitalmars-d-learn
On Tuesday, 26 April 2022 at 23:00:57 UTC, cc wrote: If your draw code doesn't depend on any scoped state you can use `function()` instead of `delegate()` to save a GC call. `scope delegate` also works here and just reuses the stack.

Re: Beginner memory question.

2022-04-16 Thread Adam Ruppe via Digitalmars-d-learn
On Saturday, 16 April 2022 at 20:41:25 UTC, WhatMeWorry wrote: Is virtual memory entering into the equation? Probably. Memory allocated doesn't physically exist until written to a lot of the time.

Re: TIC-80 WebAssembly: pointers to fixed addresses

2022-04-16 Thread Adam Ruppe via Digitalmars-d-learn
On Saturday, 16 April 2022 at 14:29:09 UTC, Pierce Ng wrote: ``` pub const FRAMEBUFFER: *allowzero volatile [16320]u8 = @intToPtr(*allowzero volatile [16320]u8, 0); pub const TILES : *[8192]u8 = @intToPtr(*[8192]u8, 0x4000); pub const SPRITES : *[8192]u8 = @intToPtr(*[8192]u8, 0x6000); ``` I b

Re: arsd.minigui

2022-04-03 Thread Adam Ruppe via Digitalmars-d-learn
On Sunday, 3 April 2022 at 16:58:03 UTC, JG wrote: Hi, I have an png image that I generate (via pdf via pdflatex) that I want to scale and display in a widget. Is this possible via something in arsd? I tried resizeImage but that doesn't seem to do what I expect. Any suggestions? Which resiz

Re: arsd-minigui - couple of questions

2022-03-28 Thread Adam Ruppe via Digitalmars-d-learn
In fact, using a pragma now, I think I got it so you don't even need the manifest now (the pragma includes a default one now). Only works when doing dmd -m32mscoff or dmd -m64 builds (which are also what dub uses fyi), will NOT work with a default dmd no-switch build.

Re: arsd-minigui - couple of questions

2022-03-28 Thread Adam Ruppe via Digitalmars-d-learn
oooh it actually is even easier than I thought, just a changed flag plus the manifest. Just pushed to minigui master. only ended up being 4 lines for this little thing. Try rebuilding with that AND be sure to use the manifest file too, same as dwt. Then you should be able to find some joy.

Re: arsd-minigui - couple of questions

2022-03-28 Thread Adam Ruppe via Digitalmars-d-learn
On Monday, 28 March 2022 at 21:10:47 UTC, Sai wrote: FWIW, DWT which uses native controls on windows can show transparent pngs and also both image & text at the same time. However I had to add the following app.exe.manifest Yeah, this tells me they used owner-drawn buttons, which is only supp

Re: arsd-minigui - couple of questions

2022-03-28 Thread Adam Ruppe via Digitalmars-d-learn
On Monday, 28 March 2022 at 17:00:42 UTC, sai wrote: 1. I assume arsd-minigui library does not support transparent images by itself, does it? I am trying to show a png image with transparent areas on a button, but those transparent areas shows as black color. Well, I tried forwarding the flag

Re: arsd-minigui - couple of questions

2022-03-28 Thread Adam Ruppe via Digitalmars-d-learn
On Monday, 28 March 2022 at 17:00:42 UTC, sai wrote: 1. I assume arsd-minigui library does not support transparent images by itself, does it? I am trying to show a png image with transparent areas on a button, but those transparent areas shows as black color. I added that to simpledisplay las

Re: Basic question about size_t and ulong

2022-03-18 Thread Adam Ruppe via Digitalmars-d-learn
On Friday, 18 March 2022 at 21:54:55 UTC, WhatMeWorry wrote: Isn't ulong an integer? And isn't memory addresses 64 bits long? Only if you are doing a 64 bit build. Try using -m64

Re: static init c struct with array filed

2022-03-16 Thread Adam Ruppe via Digitalmars-d-learn
On Thursday, 17 March 2022 at 00:16:39 UTC, Mike Parker wrote: On Wednesday, 16 March 2022 at 07:27:06 UTC, test wrote: ```c struct Test { int32_t a; } struct Test2 { int32_t a; Test arr[]; } ``` I need static const init Test2, then pass it to c library late(third library, can not

Re: forward tuple arg to local variable + dtor

2022-01-22 Thread Adam Ruppe via Digitalmars-d-learn
You can't forward to a local variable. Local variables will be a copy of the tuple. forward only actually works if sent *directly* to another function call. There's a bunch of things in D that only work in function parameter lists and not local variables. This is one of them.

Re: Using getSymbolsByUDA in a static foreach loop

2022-01-19 Thread Adam Ruppe via Digitalmars-d-learn
On Thursday, 20 January 2022 at 00:55:33 UTC, Jack Stouffer wrote: static foreach(member; __traits(allMembers, Manager)) member here is a string, not the member. I prefer to call it memberName. Then you __traits(getMember, Manager, memberName) to actually get the alias you can p

Re: Ambiguity issue with expanding and evaluating single template type parameter enums

2021-12-27 Thread Adam Ruppe via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 00:13:13 UTC, data pulverizer wrote: There are various requirements, sometimes I have to cast or type convert, so I **need** the type to paste correctly and explicitly. You almost never actually need types as strings. I'm almost certain there's a better way for

Re: Ambiguity issue with expanding and evaluating single template type parameter enums

2021-12-27 Thread Adam Ruppe via Digitalmars-d-learn
On Monday, 27 December 2021 at 21:21:30 UTC, data pulverizer wrote: alias T = MyType!(INTEGER); What is MyType? enum code = "writeln(\"instance: \", adder(" ~ T.stringof ~ "(), " ~ U.stringof ~ "()" ~ "));"; And why is this a string mixin instead of a plain simple function

Re: Ambiguity issue with expanding and evaluating single template type parameter enums

2021-12-27 Thread Adam Ruppe via Digitalmars-d-learn
On Monday, 27 December 2021 at 21:05:51 UTC, data pulverizer wrote: adder(MyType!MyEnum.INTEGER(), MyType!MyEnum.STRING()); The rule for !(args) is of you leave the parenthesis off, it only uses the next single token as the argument. So it will never include a dot; it is like you wrote `MyTyp

Re: How to print unicode characters (no library)?

2021-12-26 Thread Adam Ruppe via Digitalmars-d-learn
On Sunday, 26 December 2021 at 20:50:39 UTC, rempas wrote: I want to do this without using any library by using the "write" system call directly with 64-bit Linux. write just transfers a sequence of bytes. It doesn't know nor care what they represent - that's for the receiving end to figure o

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Adam Ruppe via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 22:24:42 UTC, H. S. Teoh wrote: `__gshared` is needed to coax the compiler into making the variable global in the C/C++ sense, i.e., only 1 instance across all threads. it is just normally __gshared implies static automatically. it does in like every other c

Re: Why code failed to compile for foo2?

2021-12-11 Thread Adam Ruppe via Digitalmars-d-learn
On Saturday, 11 December 2021 at 23:17:17 UTC, Stanislav Blinov wrote: ? No. If it was unsatisfied constraint, the error would've shown that. And if you try to instantiate it, you'll see it is an unsatisfied constraint anyway. There's two layers of failure here. Using Unqual there is pretty

Re: Why code failed to compile for foo2?

2021-12-11 Thread Adam Ruppe via Digitalmars-d-learn
On Saturday, 11 December 2021 at 22:50:45 UTC, apz28 wrote: void foo2(T)(Unqual!T x) if(isUnsigned!T) {} This means it treats foo2 as if it doesn't exist unless T is unsigned... onlineapp.d(15): Error: template `onlineapp.foo2` cannot deduce function from argument types `!()(int)` onlineap

Re: T... args!

2021-12-08 Thread Adam Ruppe via Digitalmars-d-learn
On Wednesday, 8 December 2021 at 23:43:48 UTC, Salih Dincer wrote: Is this not a contradiction? : and 3.1415 aren't string: ```d void foo(string...)(string args) { `string...` there is a user-defined identifier representing a mix of types. string isn't special, yo can declare your own varia

Re: How to read a single character in D language?

2021-11-19 Thread Adam Ruppe via Digitalmars-d-learn
On Friday, 19 November 2021 at 20:51:09 UTC, BoQsc wrote: But the source file overwhelmed me by its size. Yeah, the getch function in there builds on the rest of the events the library offers, so it won't be that useful outside. The OS functions for getch alone though are actually pretty s

Re: arsd.simpledisplay on macos

2021-11-16 Thread Adam Ruppe via Digitalmars-d-learn
On Tuesday, 16 November 2021 at 03:41:31 UTC, Ben Jones wrote: I'm trying to use Adam's simpledisplay on a mac with XQuartz which is installed + running. When I try to create a window, it crashes when calling `XDisplayConnection.get()`. Hmm, I have never actually seen that fail since the mac

Re: D modules

2021-11-13 Thread Adam Ruppe via Digitalmars-d-learn
On Saturday, 13 November 2021 at 22:52:55 UTC, pascal111 wrote: When I'm searching for "toUpper" and "toLower" functions that string type uses They are usable though `import std.string;` the docs just don't do a great job showing that. The newest test version of my doc generator does integra

Re: in a template, how can I get the parameter of a user defined attribute

2021-11-06 Thread Adam Ruppe via Digitalmars-d-learn
On Saturday, 6 November 2021 at 19:45:49 UTC, Chris Bare wrote: dbForeignKey!(Position) static if(is(T == dbForeignKey!Arg, Arg)) { // use Arg here }

Re: How to do a function pointer to "malloc" and "free"?

2021-10-17 Thread Adam Ruppe via Digitalmars-d-learn
On Sunday, 17 October 2021 at 23:07:15 UTC, Elmar wrote: Do you have a link for more information how to initialize the D runtime? Export a function that calls this: http://druntime.dpldocs.info/core.runtime.Runtime.initialize.html And also export a function that calls this: http://druntime.dpl

Re: How to do a function pointer to "malloc" and "free"?

2021-10-10 Thread Adam Ruppe via Digitalmars-d-learn
On Sunday, 10 October 2021 at 13:52:57 UTC, Elmar wrote: The language subset "BetterC" is required for calling D functions from C though. This is false. You can use any D features when calling it from C, you just need to provide an init and term function that is called from C that runtime in

Re: Better debugging?

2021-10-03 Thread Adam Ruppe via Digitalmars-d-learn
On Sunday, 3 October 2021 at 22:21:45 UTC, Tim wrote: -gc DMD2 compiler switch tried plain -g ? -gc is a compatibility debug thing for things with zero D support. p oboslete now

Re: Template mixin problem with EnumMembers

2021-10-02 Thread Adam Ruppe via Digitalmars-d-learn
On Saturday, 2 October 2021 at 22:07:23 UTC, Ferhat Kurtulmuş wrote: The below code works as expected on https://run.dlang.io/, but not on my computer. And I don't know why? You used .stringof. That's undefined behavior. Never use stringof. (except for debugging writes) Now, I'd actually pro

Re: Understanding range.dropBackOne

2021-09-28 Thread Adam Ruppe via Digitalmars-d-learn
On Tuesday, 28 September 2021 at 22:56:17 UTC, Tim wrote: I'm doing the following: int[25] window = 0; Note that this array has a fixed size. window = someInteger ~ window[].dropBackOne; Here the window[] takes a variable-length slice of it. Turning it from int[25] into plain int[]. Then

Re: Templates for instantiating derived class

2021-09-20 Thread Adam Ruppe via Digitalmars-d-learn
On Monday, 20 September 2021 at 22:16:47 UTC, rjkilpatrick wrote: auto opBinary(string op)(int rhs) const if (op == "+") { return new Super(_a + rhs); // Creates of type Super even when called from derived class } Make this auto opBinary(string op, this This)(int rhs) ...

Re: interface function member declarations needing parameter attributes ?

2021-07-17 Thread Adam Ruppe via Digitalmars-d-learn
On Saturday, 17 July 2021 at 20:42:06 UTC, someone wrote: From the interface perspective: are these signatures identical or not ? No, they are very different. But you also don't gain much from const here and that ref is probably actively harmful so i wouldn't use them here.

Re: function parameters: is it possible to pass byref ... while being optional at the same time ?

2021-07-17 Thread Adam Ruppe via Digitalmars-d-learn
On Saturday, 17 July 2021 at 20:49:58 UTC, someone wrote: ref classTickerID robjTickerID Why are you using ref here at all? You probably shouldn't be using it. But if it is legitimately needed you can do a pointer instead of ref.

Re: UFCS doubt

2021-07-08 Thread Adam Ruppe via Digitalmars-d-learn
On Thursday, 8 July 2021 at 22:24:26 UTC, Antonio wrote: I supossed that ```mfp(c,20)``` and ```c.mfp(20)``` should be equivalent because UFCS in second example, but it is not... why? UFCS only works with functions defined at top level, not nested inside other functions. That's just how it is