Re: Noob ImportC questions

2025-02-27 Thread John C. via Digitalmars-d-learn
On Thursday, 27 February 2025 at 13:33:55 UTC, John C. wrote: all code I have tested worked perfectly. Of course, I had to rewrite all "RAYWHITE" to "raywhite", etc., but I'm happy to have working GUI library now!

Re: Noob ImportC questions

2025-02-27 Thread John C. via Digitalmars-d-learn
On Thursday, 27 February 2025 at 12:48:19 UTC, Kapendev wrote: On Thursday, 27 February 2025 at 08:16:33 UTC, John C. wrote: On Thursday, 27 February 2025 at 08:10:04 UTC, John C. wrote: But this change was not helpful, same error occured. Does this mean that ImportC cannot parse object

Re: Noob ImportC questions

2025-02-27 Thread John C. via Digitalmars-d-learn
On Wednesday, 26 February 2025 at 17:00:48 UTC, John C. wrote: 2. Why main.d version with "Color(...)" replaced by "RAYWHITE" or "LIGHTGREY" (defined in header) will not compile with "undefined identifier" error? I have tested some basic Raylib funct

Re: Noob ImportC questions

2025-02-27 Thread John C. via Digitalmars-d-learn
On Thursday, 27 February 2025 at 08:10:04 UTC, John C. wrote: would removing some "hard to parse" constructs in header file help this situation? I tried to change ``` #define LIGHTGRAY CLITERAL(Color){ 200, 200, 200, 255 } // Light Gray ``` To more simpler definition whic

Re: Noob ImportC questions

2025-02-27 Thread John C. via Digitalmars-d-learn
On Wednesday, 26 February 2025 at 18:53:40 UTC, Kapendev wrote: On Wednesday, 26 February 2025 at 17:00:48 UTC, John C. wrote: Error (with both commands above, same result): ``` main.d(8): Error: undefined identifier `RAYWHITE` main.d(9): Error: undefined identifier `LIGHTGRAY` ``` Both

Re: Noob ImportC questions

2025-02-26 Thread John C. via Digitalmars-d-learn
On Wednesday, 26 February 2025 at 21:08:19 UTC, monkyyy wrote: I think `import raylib` finds raylib.c Thank you, it were actually using raylib.c in both cases. When I renamed this file, import was made impossible (I think it should have happened?)

Noob ImportC questions

2025-02-26 Thread John C. via Digitalmars-d-learn
Hello everyone. Recently I get interested in some GUI-related stuff and I want to use Raylib in my project. I know about raylib-d, dray, etc. bindings, but I would like to see what can ImportC do for me in this situation. I have following project hierarchy: ``` project/ src/ main.d ra

Re: core.simd and dynamic arrays

2025-01-27 Thread John C. via Digitalmars-d-learn
On Monday, 27 January 2025 at 15:55:17 UTC, Guillaume Piolat wrote: You may use intel-intrinsics who: 1. guarantees float8 is there 2. have aligned malloc _mm_malloc I have heard about intel-intrinsics and it's really good idea to use it in my code, but I wanted to try some SIMD operations wit

Re: core.simd and dynamic arrays

2025-01-26 Thread John C. via Digitalmars-d-learn
On Monday, 27 January 2025 at 05:53:09 UTC, John C. wrote: Print out the pointer to `a[0]` to verify what the actual alignment is. If we look to output above, first line addresses are aligned to 32 bytes Except address with B(1011) at second from the right position?

Re: core.simd and dynamic arrays

2025-01-26 Thread John C. via Digitalmars-d-learn
On Sunday, 26 January 2025 at 16:43:19 UTC, Johan wrote: The `align(32)` applies to the slice `a`, not the contents of `a` (where `a` points to). Thank you, seems that it is reason for that errors. I remember that dynamic array can be represented as structure with size_t len and pointer to me

Re: core.simd and dynamic arrays

2025-01-26 Thread John C. via Digitalmars-d-learn
On Sunday, 26 January 2025 at 13:59:09 UTC, John C. wrote: I have tested this code with LDC on run.dlang.io, segmentation fault does occur only if -mattr=+avx is used. Without this flag no errors are produced. Actually, if I use -mcpu=avx with DMD, no error is generated. However, if this

Re: core.simd and dynamic arrays

2025-01-26 Thread John C. via Digitalmars-d-learn
On Sunday, 26 January 2025 at 12:45:11 UTC, John C. wrote: I'm using LDC compiler 1.36.0 on x86_64 Linux system with "-w -O3 -mattr=+avx" compiler flags. I have tested this code with LDC on run.dlang.io, segmentation fault does occur only if -mattr=+avx is used. Without this

Re: core.simd and dynamic arrays

2025-01-26 Thread John C. via Digitalmars-d-learn
On Sunday, 26 January 2025 at 12:56:55 UTC, ryuukk_ wrote: LDC 1.36 = 1 years old latest version is LDC 1.40 with LDC 1.40, your code works on my computer now my turn to ask a question: why were you using a 1 years old compiler version? common sense would be to make sure you are up to dat

core.simd and dynamic arrays

2025-01-26 Thread John C. via Digitalmars-d-learn
Hello everyone. I am complete newbie in D and programming at all and I can't understand why dynamic arrays can't be used within following D code: ```d import std.random : uniform01; import core.simd; void main() { align(32) float[] a = new float[128]; align(32) float[] b = new float[128

How to do conditional scope(exit) ?

2024-12-18 Thread John Dougan via Digitalmars-d-learn
=== A F == 2 == A b c scope exit 2 F == end === ``` which isn't what I want. The case for `test(1)` is fine. For `test(2))` I want the `scope exit 2` to come after the `F`. Is there a way to tell it that I want to use an enclosing scope or make it ignore the scope on the `if`? Cheers, -- John

Re: How does one attach a manifest file to a D executable on Windows?

2024-06-02 Thread John Chapman via Digitalmars-d-learn
On Sunday, 2 June 2024 at 21:46:41 UTC, solidstate1991 wrote: Well, it turns out I used the windres found in mingw instead of `rc.exe` since the latter cannot be found anywhere on my PC, even after reinstalling stuff. I need to hunt it down somehow. rc.exe comes with the Windows SDK - it gets

Re: How does one attach a manifest file to a D executable on Windows?

2024-05-25 Thread John Chapman via Digitalmars-d-learn
On Saturday, 25 May 2024 at 13:13:08 UTC, solidstate1991 wrote: No, I meant something like this: https://learn.microsoft.com/en-us/windows/win32/controls/cookbook-overview Not tested but from memory I do this: 1) Copy that first XML snippet from the page you linked, save to a file called exa

Re: How can I tell D that function args are @nogc etc.

2024-04-12 Thread John Dougan via Digitalmars-d-learn
On Friday, 12 April 2024 at 15:08:50 UTC, Steven Schveighoffer wrote: On Friday, 12 April 2024 at 03:57:40 UTC, John Dougan wrote: What is the procedure for bug reporting? I'm looking at the issues tracker and have no clue how to drive the search to see if this is already there.

Re: How can I tell D that function args are @nogc etc.

2024-04-11 Thread John Dougan via Digitalmars-d-learn
. What is the procedure for bug reporting? I'm looking at the issues tracker and have no clue how to drive the search to see if this is already there. -Steve -- john

Re: How can I tell D that function args are @nogc etc.

2024-04-10 Thread John Dougan via Digitalmars-d-learn
like attribute ordering. -- john

How can I tell D that function args are @nogc etc.

2024-04-09 Thread John Dougan via Digitalmars-d-learn
`onlineapp.processSafely!(1, 4)` error instantiating ``` Why isn't this working? How can I get the effect I want? Cheers, -- john ``` bool[7] stagesToProcess = false; @nogc nothrow @safe bool shouldDoInStages(int index) { return stagesToProcess[index]; } @nogc nothrow @safe bool shouldDoNever(int

Re: Disable wrilten buf in docker

2024-03-12 Thread john rath via Digitalmars-d-learn
I'm glad you find it helpful! If you have any more questions, whether it's about fashion or anything else, feel free to ask. I'm here to assist you with any information or insights you might need.https://vjackets.com/

Re: SIGSEGV (Segmentation Fault) upon setting character in char array (object member var)

2023-12-19 Thread John Kiro via Digitalmars-d-learn
On Tuesday, 19 December 2023 at 14:01:31 UTC, John Kiro wrote: Thanks Adam. I agree, the behavior associated with the initialization here is confusing (compared for example to a similarly-looking code in Java). Also I don't get why an array of characters would be considered as an immu

Re: SIGSEGV (Segmentation Fault) upon setting character in char array (object member var)

2023-12-19 Thread John Kiro via Digitalmars-d-learn
Thanks Adam. I agree, the behavior associated with the initialization here is confusing (compared for example to a similarly-looking code in Java). Also I don't get why an array of characters would be considered as an immutable array of characters (that is a **string**). I agree this could be a

SIGSEGV (Segmentation Fault) upon setting character in char array (object member var)

2023-12-19 Thread John Kiro via Digitalmars-d-learn
#x27;; //ERROR: segmentation fault (code -11)! debug writefln("CharArray becomes %s (PROGRAM ABORTS BEFORE IT ACTUALLY!)", charArray); } } Output: $ dub run Starting Performing "debug" build using /home/john/dlang/dmd-2.106.0/

Re: What's dxml DOMEntity(R) type ?

2023-06-05 Thread John Xu via Digitalmars-d-learn
On Monday, 5 June 2023 at 10:43:27 UTC, Ferhat Kurtulmuş wrote: On Monday, 5 June 2023 at 10:01:01 UTC, John Xu wrote: The parseDOM returns a DOMEntity(R) type, how do I write a xmlRoot as global variable? I need its detailed type (auto / Variant doesn't work). import dxm

What's dxml DOMEntity(R) type ?

2023-06-05 Thread John Xu via Digitalmars-d-learn
The parseDOM returns a DOMEntity(R) type, how do I write a xmlRoot as global variable? I need its detailed type (auto / Variant doesn't work). import dxml.dom; ?? xmlRoot; int main() { string xml = readText("a.xml"); auto dom = parseDOM(xml);

Re: How get struct value by member name string ?

2023-06-01 Thread John Xu via Digitalmars-d-learn
A correction: string getTMember(T t, string columnName) { foreach(member; __traits(allMembers, T)){ if (member == columnName) { return __traits(getMember, t, member).to!string; } } return ""; }

Re: How get struct value by member name string ?

2023-06-01 Thread John Xu via Digitalmars-d-learn
On Thursday, 1 June 2023 at 15:38:08 UTC, Steven Schveighoffer wrote: On 5/31/23 12:08 AM, John Xu wrote: When render vibe.d diet template,     string[] allMembers = __traits(allMembers, t); enum allMembers = __traits(allMembers, t);     res.render!("index.dt", t, allMemb

Re: How get struct value by member name string ?

2023-05-30 Thread John Xu via Digitalmars-d-learn
On Tuesday, 30 May 2023 at 15:43:12 UTC, Steven Schveighoffer wrote: On 5/30/23 4:46 AM, John Xu wrote: How to put above enum as a function parameter? Following code wouldn't work:     string getTMember(T t, enum string memberName) {     return __traits(getMember, t, membe

Re: How get struct value by member name string ?

2023-05-30 Thread John Xu via Digitalmars-d-learn
On Tuesday, 30 May 2023 at 01:33:54 UTC, H. S. Teoh wrote: On Tue, May 30, 2023 at 01:24:46AM +, John Xu via Digitalmars-d-learn wrote: On Monday, 29 May 2023 at 11:21:11 UTC, Adam D Ruppe wrote: > On Monday, 29 May 2023 at 09:35:11 UTC, John Xu wrote: > > Error: variabl

Re: How get struct value by member name string ?

2023-05-29 Thread John Xu via Digitalmars-d-learn
On Monday, 29 May 2023 at 11:21:11 UTC, Adam D Ruppe wrote: On Monday, 29 May 2023 at 09:35:11 UTC, John Xu wrote: Error: variable `column` cannot be read at compile time you should generally getMember on a variable T t; __traits(getMember, t, "name") like that, that's

How get struct value by member name string ?

2023-05-29 Thread John Xu via Digitalmars-d-learn
I saw ddbc (https://github.com/buggins/ddbc/blob/master/source/ddbc/pods.d) uses static if (__traits(compiles, (typeof(__traits(getMember, T, m) { __traits(getMember, T, m) } But for my experience, above code sometimes/somewhere works, sometimes/somewhere just doesn't:

How hide console in dub.sdl under windows 11?

2023-05-25 Thread John Xu via Digitalmars-d-learn
For dmd, I can use a no_console.def file, which has: EXETYPE NT SUBSYSTEM WINDOWS Then `dmd my.d no_console.def` to hide console. But how do I realize it with dub.sdl ? Adding no_console.def to "sourceFiles", doesn't help.

Best way to convert between GBK/GB18030 to utf8 ?

2023-05-22 Thread John Xu via Digitalmars-d-learn
What is the best way to convert a GBK/GB18030 file contents, i.e. read via: std.stdio.read(gbkFile).to!string , to utf8 encoding ?

Re: Can dmd compile a favicon.ico to exe file ?

2023-05-22 Thread John Xu via Digitalmars-d-learn
On Friday, 19 May 2023 at 21:19:07 UTC, Richard (Rikki) Andrew Cattermole wrote: On 19/05/2023 9:39 PM, John Xu wrote: On Thursday, 18 May 2023 at 15:39:05 UTC, Richard (Rikki) Andrew Cattermole wrote: On 19/05/2023 2:19 AM, John Xu wrote: On Monday, 15 May 2023 at 03:54:03 UTC, Richard

Re: Can dmd compile a favicon.ico to exe file ?

2023-05-19 Thread John Xu via Digitalmars-d-learn
On Thursday, 18 May 2023 at 15:39:05 UTC, Richard (Rikki) Andrew Cattermole wrote: On 19/05/2023 2:19 AM, John Xu wrote: On Monday, 15 May 2023 at 03:54:03 UTC, Richard (Rikki) Andrew Cattermole wrote: That is only for OMF target. You need rc that comes with Visual Studio C++ build tools

Re: Can dmd compile a favicon.ico to exe file ?

2023-05-18 Thread John Xu via Digitalmars-d-learn
On Monday, 15 May 2023 at 03:54:03 UTC, Richard (Rikki) Andrew Cattermole wrote: That is only for OMF target. You need rc that comes with Visual Studio C++ build tools. Alternatively windres from mingw may work (I haven't tested). How can I add this step to dub.sdl ?

Re: Where can I find D jobs?

2023-05-16 Thread John Xu via Digitalmars-d-learn
On Saturday, 29 April 2023 at 00:31:21 UTC, Neto wrote: On Saturday, 29 April 2023 at 00:29:28 UTC, Neto wrote: I'm thinking in moving from freelancer to some company, but I'd like to use D. Are there any companies hiring where D is used? note: hire without a degree. and remote. I received

Re: Can dmd compile a favicon.ico to exe file ?

2023-05-14 Thread John Xu via Digitalmars-d-learn
On Monday, 15 May 2023 at 02:45:17 UTC, John Xu wrote: Found a related link: https://forum.dlang.org/thread/wogdypudrmrgwjysf...@forum.dlang.org Where Adam D Ruppe informed rcc.exe from http://ftp.digitalmars.com/bup.zip ... Any help? My isp.ico was converted from a png with gimp, used in C

Re: Can dmd compile a favicon.ico to exe file ?

2023-05-14 Thread John Xu via Digitalmars-d-learn
Found a related link: https://forum.dlang.org/thread/wogdypudrmrgwjysf...@forum.dlang.org Where Adam D Ruppe informed rcc.exe from http://ftp.digitalmars.com/bup.zip But, I got problem: rcc -r .\resource.rc IDI_ICON1 ICON DISCARDABLE "isp.ico" ^ .\resource.rc(1) : Error: '

Re: Can dmd compile a favicon.ico to exe file ?

2023-05-14 Thread John Xu via Digitalmars-d-learn
On Friday, 12 May 2023 at 02:09:17 UTC, ryuukk_ wrote: create a ``ressource.rc`` file and paste: ``` IDI_ICON1 ICON DISCARDABLE "myicon.ico" ``` then put your ``mycon.ico`` file next to it ``` my_project\ app.d ressource.rc myicon.ico ``` ``` dmd app.d ressource.rc Thanks for y

Can dmd compile a favicon.ico to exe file ?

2023-05-11 Thread John Xu via Digitalmars-d-learn
I saw c# program's exe, often have an favicon.ico image bound together, which can be dragged to desktop. Can dmd compile an icon image to an exe also?

Re: Any working REPL program on windows? DREPL doesn't compile

2023-05-11 Thread John Xu via Digitalmars-d-learn
On Thursday, 23 March 2023 at 13:27:00 UTC, jmh530 wrote: I've composed a simple gui, partially solved my problem: to compile/test simple codes quickly: https://github.com/xucs007/dln

Re: Getting a total from a user defined variable

2023-04-20 Thread John Chapman via Digitalmars-d-learn
On Thursday, 20 April 2023 at 19:41:21 UTC, Joel wrote: // how do I get the total of ages added together? p.map!(x => x.age).sum();

Re: How can a function pointer required to be extern(C)?

2023-04-12 Thread John Chapman via Digitalmars-d-learn
On Wednesday, 12 April 2023 at 20:36:59 UTC, H. S. Teoh wrote: ---snip--- extern(C) void* abc(void*) {return null;} alias FuncPtr = typeof(&abc); You can also express it like this: ```d extern(C) alias FuncPtr = void* function(void*); ```

Re: mutable pointers as associative array keys

2023-04-11 Thread John Colvin via Digitalmars-d-learn
On Monday, 10 April 2023 at 20:31:43 UTC, Steven Schveighoffer wrote: On 4/10/23 4:25 PM, Steven Schveighoffer wrote: It's also completely useless. Having const keys does nothing to guarantee unchanging keys. Another half-assed attempt to be encode correct semantics but fails completely in its

mutable pointers as associative array keys

2023-04-10 Thread John Colvin via Digitalmars-d-learn
It seems that it isn't possible, am I missing something? alias Q = int[int*]; pragma(msg, Q); // int[const(int)*] Also, is this documented somewhere?

Any working REPL program on windows? DREPL doesn't compile

2023-03-23 Thread John Xu via Digitalmars-d-learn
Anybody know any working REPL program? I failed to find a working one. https://github.com/dlang-community/drepl can't compile on my Windows 10, dub reports: src\drepl\engines\dmd.d(258,16): Error: undefined identifier `dlsym`

How to expand wildchar under dos ?

2023-03-09 Thread John Xu via Digitalmars-d-learn
Under dos, how to get wildchar matched file names? PS E:> dmd a.d PS E:> .\a.exe a.* args=["a.exe", "a.*"] d-glob doesn't function well under windows dos either.

Re: Best way to read/write Chinese (GBK/GB18030) files?

2023-03-09 Thread John Xu via Digitalmars-d-learn
I found this: https://github.com/meatatt/exCode/blob/master/source/excode/package.d There is mention of unicode/GBK conversion, maybe it could be helpful Thanks for quick answers. Now I found I can read both UTF8 and UTF-16LE chinese file: string txt = std.file.read(chineseFile).to!stri

Best way to read/write Chinese (GBK/GB18030) files?

2023-03-06 Thread John Xu via Digitalmars-d-learn
I'm new to dlang. I didn't find much tutorials on internet about how to read/write Chinese easily. std.encoding doesn't seem to support GBK or GB18030: "Encodings currently supported are UTF-8, UTF-16, UTF-32, ASCII, ISO-8859-1 (also known as LATIN-1), ISO-8859-2 (LATIN-2), WINDOWS-1250, WIND

Re: staticMap but with two arguments

2023-02-09 Thread John Chapman via Digitalmars-d-learn
On Thursday, 9 February 2023 at 19:17:55 UTC, Ali Çehreli wrote: I could not figure out eliminating the hard-coded 4. Can we introspect the parameter list of a template like 'fun' in the example? If we could, then we could get 4 that way. Thank you for this. I don't mind hard-coding the N argu

Re: staticMap but with two arguments

2023-02-08 Thread John Chapman via Digitalmars-d-learn
On Monday, 6 February 2023 at 09:17:07 UTC, Ali Çehreli wrote: I adapted staticMap's implementation to two sets of arguments: So I've got this implementation, but wonder if I can generalise the arg splitting portion rather than write it manually for each N? ```d template staticMapN(size_t N

Re: staticMap but with two arguments

2023-02-06 Thread John Chapman via Digitalmars-d-learn
On Monday, 6 February 2023 at 09:17:07 UTC, Ali Çehreli wrote: I adapted staticMap's implementation to two sets of arguments: Thanks Ali, that's perfect. I thought of splitting the args in half a few hours later but hadn't got around to trying it.

staticMap but with two arguments

2023-02-05 Thread John Chapman via Digitalmars-d-learn
I have two AliasSeqs: one containing a function's parameters (SourceSeq), the other containing the types I want to convert said parameters to (TargetSeq). I'd use something like staticMap to call the conversion function with both a parameter from SourceSeq and a type from TargetSeq, and return

Re: Mixin helper help

2023-01-14 Thread John Chapman via Digitalmars-d-learn
On Friday, 13 January 2023 at 14:32:44 UTC, Salih Dincer wrote: Why not directly use the mixin template for opDispatch()? My opDispatch generates code based on the arguments passed, interpolating variable names and functions based on the type. I wanted to remove the double braces in my static

Mixin helper help

2023-01-12 Thread John Chapman via Digitalmars-d-learn
I'm obviously doing something wrong, but don't quite understand. ```d mixin template helper() { mixin("writeln(12);"); } struct Foo { void opDispatch(string name)() { import std.stdio; mixin helper!(); //mixin("writeln(12);"); } } void main() { Foo.init.opDispatch!"bar"(); }

Re: How to add struct definition?

2022-09-08 Thread John Chapman via Digitalmars-d-learn
On Friday, 9 September 2022 at 00:16:01 UTC, Injeckt wrote: I need to add this struct definition in my project. But how to do that? This structure: https://docs.microsoft.com/en-us/windows/win32/api/iptypes/ns-iptypes-ip_adapter_info It's defined in DRuntime, so you can just import the module

Re: Are there any containers that go with allocators?

2021-02-09 Thread John Burton via Digitalmars-d-learn
On Tuesday, 9 February 2021 at 12:23:52 UTC, rikki cattermole wrote: https://github.com/dlang-community/containers It uses the older design for allocators (dependency). Looks good, thank you

Are there any containers that go with allocators?

2021-02-09 Thread John Burton via Digitalmars-d-learn
Normally I'm happy with the GC containers in D, they work well and suit my use. I have a few uses that would benefit from allocation in memory arenas or local stack based allocation. Looks like std.experimental has allocators for those use cases. But I can't find any containers to make use o

Re: winapi, dll

2020-10-15 Thread John Chapman via Digitalmars-d-learn
On Thursday, 15 October 2020 at 20:13:37 UTC, Atmosfear wrote: On Thursday, 15 October 2020 at 16:32:06 UTC, Imperatorn wrote: On Thursday, 15 October 2020 at 12:45:42 UTC, Atmosfear wrote: I didn't find how to call the queryperformancecounter function. I tried this. Returns errors, doesn't kno

Re: I need "windowsx.d" Someone can send It to me?

2020-09-26 Thread John Chapman via Digitalmars-d-learn
On Friday, 25 September 2020 at 15:03:56 UTC, Marcone wrote: I need windowsx.d but for I don't know the reason is not in dmd. Someone that have it can send to me? I don't know convert windowsx.h to windowsx.d windowsx.h is mostly a bunch of macros that forward to functions elsewhere in the SD

Re: Access violation when using IShellFolder2

2020-09-10 Thread John Chapman via Digitalmars-d-learn
On Thursday, 10 September 2020 at 13:30:15 UTC, FreeSlave wrote: Thanks. I tried this, but VarDateFromStr does not succeed for me. It turns out the shell embeds some control characters in the string, specifically 8206 and 8207. So remove those before passing it to VarDateFromStr. auto temp

Re: Access violation when using IShellFolder2

2020-09-09 Thread John Chapman via Digitalmars-d-learn
On Wednesday, 9 September 2020 at 22:44:50 UTC, FreeSlave wrote: Btw do you know how to parse a date returned by GetDetailsOf? Couldn't find any examples in C++. I actually can see digits representing date and time as a part of the string, but I would prefer to use some winapi function to trans

Re: Access violation when using IShellFolder2

2020-09-09 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 8 September 2020 at 22:24:22 UTC, FreeSlave wrote: However if I change the type of recycleBin variable to IShellFolder (not IShellFolder2), the crash does not happen. Does IShellFolder2 require some special handling? The issue is caused by druntime's definition of IShellFolder2. T

Re: Contributing to D wiki

2020-07-30 Thread John Burton via Digitalmars-d-learn
On Monday, 27 July 2020 at 16:58:13 UTC, H. S. Teoh wrote: On Mon, Jul 27, 2020 at 11:39:32AM +, John Burton via Digitalmars-d-learn wrote: [...] I tried looking there for information and examples of getting glfw3 statically linked into my program using LDC and didn't really find any

Re: Contributing to D wiki

2020-07-27 Thread John Burton via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 22:18:47 UTC, H. S. Teoh wrote: On Wed, Jul 15, 2020 at 09:27:22PM +, tastyminerals via Digitalmars-d-learn wrote: [...] D wiki is badly outdated. This is not a fact but a gut feeling after reading through some of its pages. I was wondering who's owning it myse

Re: Static link of glfw3 library fails for me

2020-07-27 Thread John Burton via Digitalmars-d-learn
On Monday, 27 July 2020 at 08:53:25 UTC, Mike Parker wrote: On Monday, 27 July 2020 at 07:30:42 UTC, John Burton wrote: For reference I got this to work by doing the following :- 1) Installed visual studio build tools. I could not get this to work at all with the linker etc that comes with

Re: Static link of glfw3 library fails for me

2020-07-27 Thread John Burton via Digitalmars-d-learn
On Sunday, 26 July 2020 at 12:24:06 UTC, John Burton wrote: On Sunday, 26 July 2020 at 10:41:27 UTC, Mike Parker wrote: On Sunday, 26 July 2020 at 08:28:29 UTC, John Burton wrote: And I get the following errors from the link :- lld-link: error: undefined symbol: __GSHandlerCheck lld-link

Re: Static link of glfw3 library fails for me

2020-07-26 Thread John Burton via Digitalmars-d-learn
On Sunday, 26 July 2020 at 10:41:27 UTC, Mike Parker wrote: On Sunday, 26 July 2020 at 08:28:29 UTC, John Burton wrote: And I get the following errors from the link :- lld-link: error: undefined symbol: __GSHandlerCheck lld-link: error: undefined symbol: __security_check_cookie lld-link

Static link of glfw3 library fails for me

2020-07-26 Thread John Burton via Digitalmars-d-learn
I'm trying to replicate a program I make in C++ using D. I am using the ldc2 compiler and want to *static* link in the glfw library. Following the docs I have an dub.sdl file that looks like the one below. The library I'm linking with is the vs2019 one from the GLFW zip file from their websit

Re: final switch problem

2020-06-13 Thread John Chapman via Digitalmars-d-learn
On Saturday, 13 June 2020 at 15:33:55 UTC, Boris Carvajal wrote: On Saturday, 13 June 2020 at 09:02:21 UTC, John Chapman wrote: Is this a bug or have I made a mistake? This worked a few days ago and I haven't changed my setup since then. https://issues.dlang.org/show_bug.cgi?id=19548

final switch problem

2020-06-13 Thread John Chapman via Digitalmars-d-learn
If I use a final switch and import std.uni (or any other module that imports it, such as std.string), I'm getting unresolved external symbol errors with DMD 2.092. This code triggers the issue: --- module test; import std.uni; enum Cheese { cheddar, edam } void test(Cheese cheese) { final

Re: How to get the pointer of "this" ?

2020-05-26 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 13:37:22 UTC, Vinod K Chandran wrote: On Tuesday, 26 May 2020 at 12:41:20 UTC, John Chapman wrote: On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote: Here is my full code. Please take a look. https://pastebin.com/av3nrvtT Change line 124 to

Re: How to get the pointer of "this" ?

2020-05-26 Thread John Chapman via Digitalmars-d-learn
On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote: Here is my full code. Please take a look. https://pastebin.com/av3nrvtT Change line 124 to: SetWindowSubclass(this.mHandle, SUBCLASSPROC(&btnWndProc), UINT_PTR(subClsID), cast(DWORD_PTR)cast(void*)this); That is, change `&this`

Re: How to get the pointer of "this" ?

2020-05-25 Thread John Burton via Digitalmars-d-learn
On Monday, 25 May 2020 at 16:39:30 UTC, Mike Parker wrote: On Monday, 25 May 2020 at 08:39:23 UTC, John Burton wrote: I believe that in D *this* is a reference to the object and not a pointer like in C++. So I think that writing &this might be what you need? No. A class reference

Re: How to get the pointer of "this" ?

2020-05-25 Thread John Burton via Digitalmars-d-learn
On Sunday, 24 May 2020 at 17:40:10 UTC, bauss wrote: On Sunday, 24 May 2020 at 17:05:16 UTC, Vinod K Chandran wrote: [...] I think your issue might be elsewhere because casting this should be fine and it should not complain about that in your given code. At least you should be able to pass

Overload function template for rectangular array

2020-05-25 Thread John Chapman via Digitalmars-d-learn
Is it possible to overload a function template for rectangular arrays? Is there any way to tell them apart from normal ones? void foo(T)(T[] a) {} void foo(T)(T[][] a) {} auto ra = new int[][](5, 5); ra.foo(); // matches both Thanks for any hints.

Re: Objective C protocols

2020-05-17 Thread John Colvin via Digitalmars-d-learn
On Saturday, 16 May 2020 at 19:14:51 UTC, John Colvin wrote: What's the best way to implement an Objective C protocol in D? I see mention here https://dlang.org/changelog/2.085.0.html#4_deprecated_objc_interfaces but it's not clear where things are these days. Based on some exper

Objective C protocols

2020-05-16 Thread John Colvin via Digitalmars-d-learn
What's the best way to implement an Objective C protocol in D? I see mention here https://dlang.org/changelog/2.085.0.html#4_deprecated_objc_interfaces but it's not clear where things are these days.

Re: Easy way to format int in pragma msg ?

2020-05-14 Thread John Chapman via Digitalmars-d-learn
On Thursday, 14 May 2020 at 09:49:15 UTC, wjoe wrote: Is there an easy way to print an int in hexadecimal, octal or binary representation ? The documentation on pragma(msg, ...) and a quick web search didn't provide an answer. import std.string; pragma(msg, format("%x", 10)); %x = hex %

Is it safe in D to cast pointers to structures like this?

2020-01-14 Thread John Burton via Digitalmars-d-learn
After years of C++ I have become paranoid about any casting of pointers being undefined behavior due to aliasing so want to see if :- 1) This is safe to do in D. 2) If not is there anything I can do to make it safe. 3) If not, what is the best approach? I have a void* pointing to a block of al

Re: Win32 Api: How create Open/"Save as" Dialog?

2020-01-11 Thread John Chapman via Digitalmars-d-learn
On Saturday, 11 January 2020 at 10:34:34 UTC, Marcone wrote: This code works, but I can't get file Path. Someone can help me? import std; import core.sys.windows.windows; pragma(lib, "comdlg32"); void main(){ OPENFILENAME ofn; wchar* szFileName; You need to supply a buffer, not a poin

Re: ... use of ... is hidden by ...; use alias ... to introduce base class overload set ??

2019-10-21 Thread John Chapman via Digitalmars-d-learn
On Sunday, 20 October 2019 at 21:45:35 UTC, Robert M. Münch wrote: class myWidget : Observer!message {...} class FilterSubject : SubjectObject!message { Disposable subscribe(myWidget observer){...} } I tried to add "alias subscribe = SubjectObject.subscribe;" in different places, but that di

Re: A proper WAT moment

2019-10-15 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 October 2019 at 19:45:11 UTC, Paul Backus wrote: On Monday, 14 October 2019 at 17:00:56 UTC, John Colvin wrote: Different ability to access a property depending if I'm inside something else when I look? [snip] You're attempting to call one of S's member functi

A proper WAT moment

2019-10-14 Thread John Colvin via Digitalmars-d-learn
Different ability to access a property depending if I'm inside something else when I look? struct S { int a; static int b; int c() { return a; } static int d() { return 3; } int e() @property { return a; } static int f() @property { return 3; } } void foo(S s) { prag

How to find what is causing a closure allocation

2019-10-02 Thread John Colvin via Digitalmars-d-learn
I have a function that allocates a closure somewhere in it (as shown by the result of -profile=gc). I can't make the function nogc as it calls a lot of other GC using code. profilegc.log only gives me the line number of the function signature, which doesn't give me any hint as to where in th

Re: Abstract classes vs interfaces, casting from void*

2019-08-11 Thread John Colvin via Digitalmars-d-learn
On Sunday, 11 August 2019 at 20:15:34 UTC, Alex wrote: On Sunday, 11 August 2019 at 16:05:20 UTC, John Colvin wrote: I'm trying to narrow down exactly what patterns work with each and how they overlap. What I was trying to get at with the abstract method thing is that abstract cl

Re: Abstract classes vs interfaces, casting from void*

2019-08-11 Thread John Colvin via Digitalmars-d-learn
On Sunday, 11 August 2019 at 15:16:03 UTC, Alex wrote: On Sunday, 11 August 2019 at 13:09:43 UTC, John Colvin wrote: Ok. What would go wrong (in D) if I just replaced every interface with an abstract class? I think there's some confusion here, because B.foo is not abstract. abstract

Re: Abstract classes vs interfaces, casting from void*

2019-08-11 Thread John Colvin via Digitalmars-d-learn
On Saturday, 10 August 2019 at 17:28:32 UTC, Alex wrote: ´´´ void main(){} interface A { void fun(); } abstract class B{ void fun(); } class C : A{ void fun(){} } class D : B{ /*override*/ void fun(){} } ´´´ case 1: interface A and class C implementing interface A: You don't need to "override"

Re: Abstract classes vs interfaces, casting from void*

2019-08-11 Thread John Colvin via Digitalmars-d-learn
On Saturday, 10 August 2019 at 17:46:37 UTC, Timon Gehr wrote: On 10.08.19 16:29, John Colvin wrote: Ok. What would go wrong (in D) if I just replaced every interface with an abstract class? interface A{} interface B{} class C: A,B{ } Yes, I know, I guess it wasn't clear unless you

Re: Abstract classes vs interfaces, casting from void*

2019-08-10 Thread John Colvin via Digitalmars-d-learn
On Saturday, 10 August 2019 at 10:11:15 UTC, Alex wrote: On Saturday, 10 August 2019 at 08:20:46 UTC, John Colvin wrote: On Friday, 9 August 2019 at 13:39:53 UTC, Simen Kjærås wrote: Thanks for the extra detail. Is there a solid reason to ever use an interface over an abstract class

Re: Abstract classes vs interfaces, casting from void*

2019-08-10 Thread John Colvin via Digitalmars-d-learn
On Saturday, 10 August 2019 at 10:02:02 UTC, Antonio Corbi wrote: On Saturday, 10 August 2019 at 08:20:46 UTC, John Colvin wrote: On Friday, 9 August 2019 at 13:39:53 UTC, Simen Kjærås wrote: Thanks for the extra detail. Is there a solid reason to ever use an interface over an abstract

Re: Abstract classes vs interfaces, casting from void*

2019-08-10 Thread John Colvin via Digitalmars-d-learn
On Friday, 9 August 2019 at 13:39:53 UTC, Simen Kjærås wrote: Thanks for the extra detail. Is there a solid reason to ever use an interface over an abstract class? (Other than multiple inheritance). I'm such a noob at anything related to OO.

Re: Abstract classes vs interfaces, casting from void*

2019-08-10 Thread John Colvin via Digitalmars-d-learn
On Friday, 9 August 2019 at 13:39:53 UTC, Simen Kjærås wrote: We're getting into somewhat advanced topics now. This is described in the Application Binary Interface page of the documentation[0]. In short: classes and interfaces both use a vtable[1] that holds pointers to each of their methods.

Re: Abstract classes vs interfaces, casting from void*

2019-08-09 Thread John Colvin via Digitalmars-d-learn
On Friday, 9 August 2019 at 13:19:14 UTC, kinke wrote: On Friday, 9 August 2019 at 12:26:59 UTC, John Colvin wrote: Why is there no "hi" between 0 and 1? Because you are treating the unadjusted object pointer as interface pointer and then call the only virtual function of that int

Abstract classes vs interfaces, casting from void*

2019-08-09 Thread John Colvin via Digitalmars-d-learn
import std.stdio; interface I { void foo(); } class C : I { override void foo() { writeln("hi"); } } abstract class AC { void foo(); } class D : AC { override void foo() { writeln("hi"); } } void main() { auto c = new C(); writeln(0); (cast(I)cast(void*)c).foo();

Re: Compiler/Phobos/Types problem — panic level due to timing.

2019-05-09 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 8 May 2019 at 11:53:34 UTC, Russel Winder wrote: On Mon, 2019-05-06 at 15:53 +, John Colvin via Digitalmars-d-learn wrote: […] pretty please show people it with UFCS: recurrence!((a, n) => a[n-1] + a[n-2])(zero, one) .dropExactly(n) .front Any particular rea

Re: Compiler/Phobos/Types problem — panic level due to timing.

2019-05-06 Thread John Colvin via Digitalmars-d-learn
On Monday, 6 May 2019 at 13:05:27 UTC, Russel Winder wrote: On Sunday, 5 May 2019 at 19:34:05 UTC, Nicholas Wilson wrote: On Sunday, 5 May 2019 at 19:18:47 UTC, lithium iodate wrote: [...] Yep https://run.dlang.io/is/XsLrRz works for me, https://run.dlang.io/is/KxY0e9 doesn't. Thanks peopl

  1   2   3   4   5   6   7   8   9   10   >