Re: Library object name collision

2023-01-24 Thread frame via Digitalmars-d-learn
On Tuesday, 24 January 2023 at 09:54:01 UTC, frame wrote: Thanks! it works well with the `-op` switch, didn't know I can do with libraries. Only drawback is that every path now stored as absolute path - any way to store only a relative one? Ah never mind, it seems only to do this with phobos

Re: Library object name collision

2023-01-24 Thread frame via Digitalmars-d-learn
On Tuesday, 24 January 2023 at 08:15:55 UTC, Richard (Rikki) Andrew Cattermole wrote: On 24/01/2023 8:59 PM, frame wrote: Also why have most objects an unique postfix in the name but those files havn't? It's mostly a `__ModuleInfoZ` or `__initZ` but not always. Symbols which end in

Library object name collision

2023-01-24 Thread frame via Digitalmars-d-learn
When creating a linker library under Windows and having module a/b/foo.d but also d/c/foo.d the linker afterwards is bailing out: .lib(foo.obj) : warning LNK4255: library contain multiple objects of the same name; linking object as if no debug info And when I did inspect the library it

Re: Why this function just decides to not call another function and do its thing instead?

2022-09-17 Thread frame via Digitalmars-d-learn
On Saturday, 17 September 2022 at 15:04:48 UTC, solidstate1991 wrote: And then instead just decides that the `localName` and `namespaceURI` pairs are not equal, and in those cases the Visual Studio debugger doesn't detect any entering into any of the `DOMString.equals` overrides, all while

Re: How to workaround on this (bug?)

2022-09-16 Thread frame via Digitalmars-d-learn
On Friday, 16 September 2022 at 23:06:35 UTC, H. S. Teoh wrote: Basically, if you pass something to .fun by value, then that value must be destroyed by .fun once it's ready to return. So if the value has a dtor, the dtor must be called upon exiting from .fun. Since Variant has a throwing

How to workaround on this (bug?)

2022-09-16 Thread frame via Digitalmars-d-learn
```d import std.variant; // error: destructor `std.variant.VariantN!32LU.VariantN.~this` is not `nothrow` void fun(Variant v) nothrow { } void main() { fun(Variant()); } ``` A reference, pointer or slice works. I could do something on the caller site but the signature of `fun()` should

Shorten template arguments in debug symbols?

2022-09-12 Thread frame via Digitalmars-d-learn
If I have a template that accepts tokenized code to build something, it will create the exact debug symbol with this argument supplied which makes the symbols hard to read and/or waste of memory. Is there any way to truncate or transform it like that? ``` app.fun!"writeln(\"Hello, World\");"

Re: Dictionary of Templated Functions

2022-09-10 Thread frame via Digitalmars-d-learn
On Saturday, 10 September 2022 at 00:24:11 UTC, jwatson-CO-edu wrote: Hello, I'm trying to create a dictionary of templated function pointers. The functions should return `bool` and take a differently-typed dynamics arrays `T[]` as an argument. This won't work as you might expect. Your

Re: synchronized/shared associative array .require error

2022-09-06 Thread frame via Digitalmars-d-learn
On Tuesday, 6 September 2022 at 10:28:53 UTC, Loara wrote: On Saturday, 3 September 2022 at 14:07:58 UTC, frame wrote: Not exactly, a synchronized class member function becomes automatically a shared one. This is not present in official documentation so other compilers different from `dmd`

Re: Forked GC explained

2022-09-06 Thread frame via Digitalmars-d-learn
On Monday, 5 September 2022 at 18:35:02 UTC, Steven Schveighoffer wrote: On 9/5/22 7:12 AM, frame wrote: And what if the programmer has no actual reference but wrongly forced a `free()` through a pointer cast? https://dlang.org/spec/garbage.html#pointers_and_gc * Do not store pointers into

Re: Forked GC explained

2022-09-05 Thread frame via Digitalmars-d-learn
On Saturday, 3 September 2022 at 14:31:31 UTC, Steven Schveighoffer wrote: On 9/3/22 9:35 AM, frame wrote: What happens if a manually `GC.free()` is called while the forked process marks the memory as free too but the GC immediately uses the memory again and then gets the notification to

Re: synchronized/shared associative array .require error

2022-09-03 Thread frame via Digitalmars-d-learn
On Saturday, 3 September 2022 at 09:49:54 UTC, Loara wrote: In current version of D language `synchronized` and `shared` are independent. In particular `shared` should be used only for basic types like integers for which atomic operations are well defined, and not for classes. Not exactly,

Forked GC explained

2022-09-03 Thread frame via Digitalmars-d-learn
I'm not sure I fully understand how it works. I know that the OS creates read only memory pages for both and if a memory section is about to be written, the OS will issue a copy of the pages so any write operation will be done in it's own copy and cannot mess up things. But then is the

Re: what's this error: allocatestack.c:384: advise_stack_range: Assertion `freesize < size' failed.

2022-08-23 Thread frame via Digitalmars-d-learn
On Tuesday, 23 August 2022 at 18:50:14 UTC, mw wrote: Hi, I got an error message when my program exits (the main functionality is done, I guess the error happened during D runtime's cleanup) : allocatestack.c:384: advise_stack_range: Assertion `freesize < size' failed. I suspect it

Re: Fixed-size OutBuffer that doesn't call .resize() automatically? (for database page buffers)

2022-08-19 Thread frame via Digitalmars-d-learn
On Friday, 19 August 2022 at 16:19:04 UTC, Gavin Ray wrote: 1. Calling `.toBytes()` on an `OutBuffer` will discard the extra bytes allocated past what was reserved and used. But this will still allocate the memory in the first place I guess (will the compiler optimize this away?) It does

Re: A GtkD issue

2022-08-19 Thread frame via Digitalmars-d-learn
On Friday, 19 August 2022 at 00:40:40 UTC, pascal111 wrote: Now, I used cmd.exe and found this new errors: "lld-link: error: undefined symbol: __D3gio5FileT12__ModuleInfoZ referenced by If you don't post the exact command you are using we can just assume what you did wrong: The linker

Re: A GtkD issue

2022-08-15 Thread frame via Digitalmars-d-learn
On Saturday, 13 August 2022 at 01:14:09 UTC, pascal111 wrote: I was following instructions from this link https://gtkdcoding.com/2019/01/11/-introduction-to-gtkDcoding.html to setup GtkD, and tried to run the example with VSCode and found these errors: How do you start compiling in

Re: My programs issues

2022-08-12 Thread frame via Digitalmars-d-learn
On Friday, 12 August 2022 at 20:16:26 UTC, pascal111 wrote: I tried under Windows using alt+9 or 6 but with no hoped result, they printed another characters. Maybe this wasn't clear. I meant keep pressing [Alt] and then [9], [6] (in turn) and then release [Alt]. It should print the

Re: My programs issues

2022-08-12 Thread frame via Digitalmars-d-learn
On Friday, 12 August 2022 at 18:43:14 UTC, pascal111 wrote: On Friday, 12 August 2022 at 16:06:09 UTC, frame wrote: On Thursday, 11 August 2022 at 20:30:54 UTC, pascal111 wrote: https://github.com/pascal111-fra/D/blob/main/proj08.d btw letters :D Please use ` (ASCII: 0x60) instead of '

Re: My programs issues

2022-08-12 Thread frame via Digitalmars-d-learn
On Thursday, 11 August 2022 at 20:30:54 UTC, pascal111 wrote: https://github.com/pascal111-fra/D/blob/main/proj08.d btw letters :D Please use ` (ASCII: 0x60) instead of ' (0x27) for the markdown format header, eg.: ```D ...``` otherwise it won't be recognized here.

Re: Acess variable that was set by thread

2022-08-08 Thread frame via Digitalmars-d-learn
On Monday, 8 August 2022 at 10:17:57 UTC, ag0aep6g wrote: By the way, is there some resource that recommends `__gshared` over `shared`? It seems that many newbies reach for `__gshared` first for some reason. Would be also good if the specs would tell more about those "guards": Unlike the

Re: "chain" vs "~"

2022-08-08 Thread frame via Digitalmars-d-learn
On Monday, 8 August 2022 at 01:05:40 UTC, pascal111 wrote: In next program, I used "insertInPlace", not "~" nor "chain", should I use "~" or it's the same as "insertInPlace"? https://github.com/pascal111-fra/D/blob/main/coco.d As you may noticed, `insertInPlace` has another purpose than

Re: Unittest Absurdity

2022-08-05 Thread frame via Digitalmars-d-learn
On Friday, 5 August 2022 at 21:24:13 UTC, Steven Schveighoffer wrote: That's not what I was talking about here. I'm talking about `-vcg-ast` not telling you how it's calling the function. Thanks for clarification. I had that in mind but wasn't sure. I first thought it just get optimized

Re: Unittest Absurdity

2022-08-05 Thread frame via Digitalmars-d-learn
On Friday, 5 August 2022 at 15:24:16 UTC, Steven Schveighoffer wrote: oof, I expected this to include the template parameters! I believe it normally does? This is a bug that should be filed. -Steve Sorry, I don't get what you takling about? The docs says: The expression: `a op= b` is

Re: Arbitrary precision decimal numbers

2022-08-05 Thread frame via Digitalmars-d-learn
On Friday, 5 August 2022 at 14:03:36 UTC, Ruby The Roobster wrote: Also, what about division and exponentiation. You can't just forward them to BigInt and get a good result, BigInt will just round to an integer for these two. There are divMod() and powmod() for BigInt but I have no idea how

Re: Arbitrary precision decimal numbers

2022-08-05 Thread frame via Digitalmars-d-learn
On Thursday, 4 August 2022 at 13:01:30 UTC, Ruby The Roobster wrote: Is there any implementation in phobos of something similar to BigInt but for non-integers as well? If there isn't is there a dub package that does this, and if so, which one? We have this:

Re: Ranges

2022-08-05 Thread frame via Digitalmars-d-learn
On Thursday, 4 August 2022 at 22:14:26 UTC, Ali Çehreli wrote: No element is copied or moved. :) Ali I know that :) I just found that this user has problems to understand basics in D, so I tried not to go in detail and keep at its kind of logical layer. It seems the better way to help

Re: Ranges

2022-08-04 Thread frame via Digitalmars-d-learn
On Thursday, 4 August 2022 at 13:08:21 UTC, pascal111 wrote: 1) Why the programmer needs to program "empty()", "front()", and "popFront()" functions for ranges while they exist in the language library? it seems there's no need to exert efforts for that.

Re: How to find all modules in a package?

2022-08-03 Thread frame via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 03:36:55 UTC, Domain wrote: I want to find out all public functions in all modules in a package. Can I do that at compile time? You can do something like that: ```d static foreach (sym; __traits(allMembers, mixin("std.string"))) { pragma(msg, sym.stringof);

Re: A look inside "filter" function defintion

2022-08-02 Thread frame via Digitalmars-d-learn
On Tuesday, 2 August 2022 at 14:58:52 UTC, pascal111 wrote: Maybe this helps: A template can be seen as a static struct too, so you can access its members with the scope operator "." and if there is only one member of the same name as the template ifself, the compiler auto completes it to

Re: A look inside "filter" function defintion

2022-08-02 Thread frame via Digitalmars-d-learn
On Tuesday, 2 August 2022 at 12:39:41 UTC, pascal111 wrote: Instantiation seems some complicated to me. I read "If a template contains members whose name is the same as the template identifier then these members are assumed to be referred to in a template instantiation:" in the provided link,

Re: A look inside "filter" function defintion

2022-08-01 Thread frame via Digitalmars-d-learn
On Monday, 1 August 2022 at 23:35:13 UTC, pascal111 wrote: This is the definition of "filter" function, and I think it called itself within its definition. I'm guessing how it works? It's a template that defines the function called "Eponymous Templates":

Re: never seed this kind problem with localtime_r

2022-08-01 Thread frame via Digitalmars-d-learn
On Monday, 1 August 2022 at 13:31:15 UTC, test123 wrote: please help me give any suggestion how to handle this problem. errno = ?

Re: Breaking ";" rule with lambda functions

2022-08-01 Thread frame via Digitalmars-d-learn
On Monday, 1 August 2022 at 14:15:31 UTC, pascal111 wrote: We all know the strange syntax of lambda function within filter algorithm like "auto r = chain(a, b).filter!(a => a > 0);". My note is, don't we break D rules by leaving ";" after lambda function syntax?! Many of D rules are taken

Re: Combining JSON arrays into a single JSON array -- better way than this?

2022-08-01 Thread frame via Digitalmars-d-learn
On Monday, 1 August 2022 at 09:01:35 UTC, ikelaiah wrote: Based in your suggestion, the snippet is now more brief. While your string attempt wasn't that bad, because loading all in memory while not necessary is wasted memory if you have large files to process. I would just process each file

Re: Combining JSON arrays into a single JSON array -- better way than this?

2022-07-31 Thread frame via Digitalmars-d-learn
On Monday, 1 August 2022 at 04:24:41 UTC, ikelaiah wrote: Hi, I've written a cli tool to merge JSON files (containing JSON array) in the current folder as a single JSON file. My algorithm: 1. Create a string to store the output JSON array as a string, 2. read each file 3. read each object

Re: Interfacing with user-supplied binary or obj file

2022-07-31 Thread frame via Digitalmars-d-learn
On Sunday, 31 July 2022 at 10:55:58 UTC, TheZipCreator wrote: So I'm making an interpreter for my custom scripting language and I want to allow users to write libraries in languages other than said scripting language (for efficiency). For example, you should be able to write a mathematics

Re: Obsecure problem 1

2022-07-30 Thread frame via Digitalmars-d-learn
On Saturday, 30 July 2022 at 23:40:44 UTC, pascal111 wrote: Provide me a free solution better than code::blocks with available gdc compiler I found. SDB@79 I don't know if's "better" but there is Visual Studio Code and IntelliJ IDEA for example. Yeah ctrl+v doesn't work on XTERM, the

Re: Obsecure problem 1

2022-07-30 Thread frame via Digitalmars-d-learn
On Saturday, 30 July 2022 at 22:13:55 UTC, pascal111 wrote: Because copying the running window contents is not allowed, I couldn't do it in Code::Blocks. Not allowed? o.O Did you try to select the text and insert it via middle mouse button in another window? Those terminals usually copy the

Re: Obsecure problem 1

2022-07-30 Thread frame via Digitalmars-d-learn
On Saturday, 30 July 2022 at 21:24:50 UTC, pascal111 wrote: I've typed a code to enjoy with my library "dcollect", and found non-understandable error: ... Running screen says: https://i.postimg.cc/G3YyCmbF/Screenshot-from-2022-07-30-23-23-59.png Why you don't copy the output instead? A

Re: Some user-made C functions and their D equivalents

2022-07-30 Thread frame via Digitalmars-d-learn
On Saturday, 30 July 2022 at 17:55:02 UTC, pascal111 wrote: I don't understand much the posting details of this forum. https://forum.dlang.org/help#about It's simple: if you want to format/style your posts rather then just using plain text, enable the Markdown option. It's similar to

Re: Some user-made C functions and their D equivalents

2022-07-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 July 2022 at 20:20:27 UTC, pascal111 wrote: I retyped again some function of C library I made before, but with D code: It's a start but you need to learn. - these functions can run into UB if you compile it without bound checking enabled - when working with arrays or

Re: Some user-made C functions and their D equivalents

2022-07-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 July 2022 at 16:45:55 UTC, pascal111 wrote: Aha! "In theory, someone could inject bad code", you admit my theory. The code would need to work and pass merge tests too. The merge reason must match in review. If someone fixes a task and additionally adds 100 LOC some should,

Re: Some user-made C functions and their D equivalents

2022-07-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 July 2022 at 16:17:16 UTC, pascal111 wrote: My friend, there is a wide deep secret world for hackers. We have no any idea about that world. Look, there is nothing called a 100% fact in our world. Believe me, what we see in software is just what "THEY" want us to see. I think

Re: Some user-made C functions and their D equivalents

2022-07-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 July 2022 at 14:57:36 UTC, pascal111 wrote: well between US and some other countries like "Russia", and they are using US products like C compilers, so with some way we have a doubt that US developed compilers with a way to accept kind of messages or something like that, so my

Re: Particular exceptions names

2022-07-27 Thread frame via Digitalmars-d-learn
On Tuesday, 26 July 2022 at 23:43:59 UTC, pascal111 wrote: In next example code, it used user-made exception, but what if I'm looking for a particular exception? from where can I get particular exception to arise it? There is no mechanism to find a particular exceptions in D. You have simple

Re: Background thread, async and GUI (dlangui)

2022-07-21 Thread frame via Digitalmars-d-learn
On Thursday, 21 July 2022 at 13:27:49 UTC, Bagomot wrote: I had this question: how can I get the value from the `task`, like how I can get from the `spawnLinked`(`ownerTid.send` and `receive`)? I'm using a `taskPool` through `arr.parallel`, but it became necessary to collect the progress

Re: std.signals: Error: static assert: "Aliases to mutable thread-local data not allowed."

2022-07-18 Thread frame via Digitalmars-d-learn
On Monday, 18 July 2022 at 10:22:16 UTC, Bagomot wrote: Why can't I do it with `std.signals`? How the to do it if I can't create static event listeners? ```d public void addEventListener(T : EventListener)(T listener) { connect(); } ``` This error comes from somewhere else in your code by

Re: How to call a function from a dll created with d ?

2022-07-08 Thread frame via Digitalmars-d-learn
On Thursday, 7 July 2022 at 17:29:42 UTC, cc wrote: Does importing dimedll into app.d properly NOT link in the functions that are exported to the DLL? When I tried something similar with dmd, I had to create a .di file containing just stubs, otherwise it looked like it was ignoring the DLL

Re: How to call a function from a dll created with d ?

2022-07-04 Thread frame via Digitalmars-d-learn
On Sunday, 3 July 2022 at 16:48:52 UTC, frame wrote: Only the -H switch or manual linker command generates a valid link to the DLL with DMD but then it's missing all the other library contents (also it needs `SimpleDllMain` or bails out linking errors to `_calloc` and Windows symbols) :\

Re: How to call a function from a dll created with d ?

2022-07-03 Thread frame via Digitalmars-d-learn
On Sunday, 3 July 2022 at 12:54:45 UTC, kinke wrote: On Sunday, 3 July 2022 at 08:15:38 UTC, frame wrote: Are you sure? 100%, just try yourself. Why would the symbol be defined in the executable? `dimedll.d` isn't compiled into the executable. The code is using Phobos std.stdio.writeln

Re: How to call a function from a dll created with d ?

2022-07-03 Thread frame via Digitalmars-d-learn
On Saturday, 2 July 2022 at 20:43:41 UTC, Vinod KC wrote: But I got this error message. dime.obj : error LNK2001: unresolved external symbol __D7dimedll12__ModuleInfoZ dime.exe : fatal error LNK1120: 1 unresolved externals Error: linker exited with status 1120 I tried the -H switch. You

Re: How to call a function from a dll created with d ?

2022-07-03 Thread frame via Digitalmars-d-learn
On Saturday, 2 July 2022 at 14:06:03 UTC, kinke wrote: With LDC, this is sufficient for this trivial example: ```d module dimedll; export void testFunc() { // export only needed when compiling with `-fvisibility=hidden` import std.stdio; writeln("This is from dll"); } ``` `ldc2

Re: How to use templates in a separate library?

2022-06-24 Thread frame via Digitalmars-d-learn
On Thursday, 23 June 2022 at 23:50:42 UTC, monkyyy wrote: On Thursday, 23 June 2022 at 08:12:32 UTC, CrazyMan wrote: linking make sure you use the -i flag when compiling But note, that would be the opposite of using a library.

Re: Null terminated character

2022-06-23 Thread frame via Digitalmars-d-learn
On Thursday, 23 June 2022 at 17:27:51 UTC, frame wrote: On Thursday, 23 June 2022 at 16:16:26 UTC, vc wrote: I've try this '\0'*10 and didn't work, i want the results be \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 One way: ```d import std.range; repeat("\0", 10).join(""); ``` If you just

Re: Null terminated character

2022-06-23 Thread frame via Digitalmars-d-learn
On Thursday, 23 June 2022 at 16:16:26 UTC, vc wrote: I've try this '\0'*10 and didn't work, i want the results be \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 One way: ```d import std.range; repeat("\0", 10).join(""); ```

Re: How to use templates in a separate library?

2022-06-23 Thread frame via Digitalmars-d-learn
On Thursday, 23 June 2022 at 08:12:32 UTC, CrazyMan wrote: I have a separate library and some template interface in it ```d interface IFoo(T) { void setValue(const(T) value); } ``` But when using it in the main program, it throws a linking error. I found that you can make a sourceLibrary

Re: getSymbolsByUDA in constructor/member functions

2022-06-16 Thread frame via Digitalmars-d-learn
On Thursday, 16 June 2022 at 09:29:36 UTC, Arafel wrote: Classes can have static members just as structs, so I don't think you always need an instance for a class either. Well, ok. So if you call `getMember` from a member function, it adds the hidden `this` reference, and this has subtle

Re: getSymbolsByUDA in constructor/member functions

2022-06-16 Thread frame via Digitalmars-d-learn
On Thursday, 16 June 2022 at 08:23:20 UTC, Arafel wrote: As you can see, it's `getMember` who is returning a reference to the `this` instance. In my view, this is a bug according the documentation and examples [1]. It might be that classes behave differently, but then it should be documented.

Re: getSymbolsByUDA in constructor/member functions

2022-06-16 Thread frame via Digitalmars-d-learn
On Wednesday, 15 June 2022 at 12:26:40 UTC, cc wrote: Why doesn't this work? There is nothing in the foreach body. ```d alias ALL = getSymbolsByUDA!(Def, XML); pragma(msg, ALL.stringof); ``` reports `tuple(this.x, this.y)`. Why is `this.` added? I can only answer this partially, I guess

Re: Comparing Exceptions and Errors

2022-06-07 Thread frame via Digitalmars-d-learn
On Tuesday, 7 June 2022 at 18:37:13 UTC, Steven Schveighoffer wrote: My very common use of `scope(failure)` for my DB code: ```d conn.exec("START TRANSACTION"); scope(success) conn.exec("COMMIT"); scope(failure) conn.exec("ROLLBACK"); ``` This is hard to encapsulate into a type, as dtors

Re: Comparing Exceptions and Errors

2022-06-07 Thread frame via Digitalmars-d-learn
On Friday, 3 June 2022 at 23:40:50 UTC, Steven Schveighoffer wrote: During the last beerconf, I wrote a short blog post about how `Error` and `Exception` are different, and why you should never continue after catching `Error`s. I know the thematics but I still wonder why we only have

Re: Execute the Shell command and continue executing the algorithm

2022-05-31 Thread frame via Digitalmars-d-learn
On Monday, 30 May 2022 at 11:18:42 UTC, Alexander Zhirov wrote: if (here is my condition termination of the program) OT: Wouldn't it be great to have ArnoldC support? ;-)

Re: Compiler switch for integer comparison/promotion to catch a simple error

2022-05-30 Thread frame via Digitalmars-d-learn
On Monday, 30 May 2022 at 13:15:12 UTC, bauss wrote: Good luck convincing Walter that this is a mistake :) Well, I'm not talking about this is a mistake, just a C-thing I think. I wouldn't even ask him about that since it's in the spec. If I could I would just clone a DMD build, disable

Compiler switch for integer comparison/promotion to catch a simple error

2022-05-28 Thread frame via Digitalmars-d-learn
Is there a compiler switch to catch this kind of error? ```d ulong v = 1; writeln(v > -1); ``` IMHO the compiler should bail a warning if it sees a logic comparison between signed and unsigned / different integer sizes. There is 50% chance that a implicit conversion was not intended.

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

2022-05-26 Thread frame via Digitalmars-d-learn
On Thursday, 26 May 2022 at 16:56:49 UTC, Marcone wrote: On Friday, 20 May 2022 at 13:16:00 UTC, frame wrote: On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote: I tried compiling now on x64 without console using -L/SUBSYSTEM:windows user32.lib -L/entry:mainCRTStartup -m64 and it

Re: Tracing/Profiling D Applications

2022-05-25 Thread frame via Digitalmars-d-learn
On Wednesday, 25 May 2022 at 21:35:07 UTC, Christian Köstlin wrote: Is there also a way to get the "real" threadid? I'm using that functions inside threads: core.sys.windows.winbase.GetCurrentThreadId on Windows core.sys.posix.pthread.pthread_self on Unix (implied pthreads are used)

Re: Cannot check function address

2022-05-25 Thread frame via Digitalmars-d-learn
On Wednesday, 25 May 2022 at 14:09:31 UTC, Steven Schveighoffer wrote: Yes, he acknowledged that too much was stripped. I also verified similar code works. But the real problem was something else. He is saying in this message "why doesn't the compiler recognize that in comparing a function

Re: Cannot check function address

2022-05-25 Thread frame via Digitalmars-d-learn
On Wednesday, 25 May 2022 at 05:56:28 UTC, Steven Schveighoffer wrote: It's a case where the compiler can't divine what you were thinking when you wrote that code ;) I see not in all cases but in mine. If the compiler sees the function isn't callable without arguments and it is inside an

Re: Cannot check function address

2022-05-24 Thread frame via Digitalmars-d-learn
On Wednesday, 25 May 2022 at 04:34:43 UTC, Steven Schveighoffer wrote: Well, you can possibly work around the type system, but I don't know what the compiler thinks you have there. This really bothers me and I put this test cases: ```d static if (isSomeFunction!fun) pragma(msg,...) static

Re: Cannot check function address

2022-05-24 Thread frame via Digitalmars-d-learn
On Wednesday, 25 May 2022 at 03:41:17 UTC, Steven Schveighoffer wrote: This is a compiler bug, at least I think so. Since the compiler is misbehaving, it's not clear how to make it behave. -Steve Well, ok, it's not my top priority and dustmite seems to run better on Unix - which I need to

Re: Cannot check function address

2022-05-24 Thread frame via Digitalmars-d-learn
On Wednesday, 25 May 2022 at 02:42:26 UTC, Steven Schveighoffer wrote: Just to be pedantic, you tried that call in the *exact place* the assert is failing to compile? D can be weird/surprising about name lookups. Yes, of course ;-) try: pragma(msg, typeof(fun)); Outputs: ``` extern

Re: Cannot check function address

2022-05-24 Thread frame via Digitalmars-d-learn
On Tuesday, 24 May 2022 at 22:18:44 UTC, Adam D Ruppe wrote: There's a big difference between a function and a function pointer. Could you please clarify in this context? `Fun` is basically generated by code like that: ```d extern (Windows) void* GetProcAddress(void*, const char*); auto fn =

Re: Cannot check function address

2022-05-24 Thread frame via Digitalmars-d-learn
On Wednesday, 25 May 2022 at 01:23:56 UTC, Steven Schveighoffer wrote: "of course" I have no idea what your real code looks like, unless you post the real code. While I get the point of trying to slim down the example to something postable, a very common problem with this kind of

Re: Cannot check function address

2022-05-24 Thread frame via Digitalmars-d-learn
On Tuesday, 24 May 2022 at 19:09:52 UTC, Steven Schveighoffer wrote: This doesn't seem valid for module-level code, assert is an instruction, not a declaration. ... Try `std.traits.fullyQualifiedName!fun` to see where it's coming from. expected 5 got 0 suggests it is finding some other

Cannot check function address

2022-05-24 Thread frame via Digitalmars-d-learn
I have a function slot that may be loaded via a shared library. I want to check if that function has an address but compiler (DMD 2.100, Windows) instead tries to invocate the function? ```d // --- module a: alias F = extern (C) void function(string param); F fun = someLibLoad!F("name");

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

2022-05-20 Thread frame via Digitalmars-d-learn
On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote: I am using a main() function. I am compiling on Windows x86 32 bits. I am using DMD 2.100.0 This error is only in version 2.100.0 of DMD. Did you try 2.099 too? Because the default build mode for 32bit was changed to MS-COFF and it

Re: Unexplainable behaviour with direct struct assignment.

2022-05-19 Thread frame via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 21:49:14 UTC, HuskyNator wrote: After updating to `DMD 2.100.0` & `DUB 1.29.0`, I still get this behavior. Only when I use `dub run --b=debug` however (default for me). `dub run --b=release` does return what one would expect. I'm still on 2098.1, Windows 10 and

Re: What are (were) the most difficult parts of D?

2022-05-14 Thread frame via Digitalmars-d-learn
On Saturday, 14 May 2022 at 04:31:48 UTC, zjh wrote: D forum should add a "`author delete`" function. Likewise, each post could add something like `votes` , good posts will naturally `come out` and be collected together. It's really convenient for beginners of `d`. This way, the similar

Re: Template shenannigans with multiple datatypes

2022-05-13 Thread frame via Digitalmars-d-learn
On Friday, 13 May 2022 at 07:32:16 UTC, Chris Katko wrote: This is a kinda "dynamic language" feature but it feels like this information is theoretically, knowable at static, compile-time. I know what the variable types will be at compile-time, but I don't know how to put them all in one

Re: Type Parameter Deduction

2022-05-10 Thread frame via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 13:14:20 UTC, Salih Dincer wrote: must satisfy the following constraint: That is your type protection here, a constraint. Alternatively you can put the constraint in a function and make it more verbose: ```d bool isAllowedType(T)() { static assert(!is(T ==

Re: Parameters of overloaded templated function

2022-05-10 Thread frame 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 But considering you're passing it as an argument, not a formal

Re: Type Parameter Deduction

2022-05-10 Thread frame via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 09:26:46 UTC, Salih Dincer wrote: However, the compiler catches other errors! How can I solve this problem? Thanks... SDB@79 What about something like this? ```d auto inclusiveRange(T = int)(T f = T(0), T l = T(0), T s = T(1)) if(!is(T == bool)) { //... }

Re: Parameters of overloaded templated function

2022-05-10 Thread frame via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 11:26:44 UTC, frame wrote: On Tuesday, 10 May 2022 at 03:18:14 UTC, Tejas wrote: Can you try Makes no difference. OK, I tried it in separate test and works. Weird, I already tried that before, there must be something wrong with my other template. Thanks

Re: Parameters of overloaded templated function

2022-05-10 Thread frame via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 03:18:14 UTC, Tejas wrote: Can you try Makes no difference.

Parameters of overloaded templated function

2022-05-09 Thread frame via Digitalmars-d-learn
So `__traits(getOverloads)` returns also templated members and `__traits(isTemplate)` can select those members. Unfortunately, `Parameters!` does not work with the templated member. How can I pass a symbol of T or A... to `Parameters!` as desired type without instantiating the template? ```d

Re: How to use destroy and free.

2022-04-25 Thread frame via Digitalmars-d-learn
On Monday, 25 April 2022 at 02:07:50 UTC, Ali Çehreli wrote: > import core.memory: GC; GC.free(GC.addrOf(cast(void *)(i.ptr))); That is wrong because you did not allocate that address yourself. Hmm? The GC did allocate here(?) On 4/24/22 17:26, Salih Dincer wrote: >

Re: What is the difference between a static assert and a unit test?

2022-04-21 Thread frame via Digitalmars-d-learn
On Thursday, 21 April 2022 at 22:26:57 UTC, Alain De Vos wrote: I don't know when to use a static assert and when to use a unit test ? There is `assert()`, `static assert()` and `unittest`. `static assert()` is used while compiling, to find errors or circumstances that can lead to errors in

Re: Odd behaviour of std.range

2022-02-22 Thread frame via Digitalmars-d-learn
On Tuesday, 22 February 2022 at 17:33:18 UTC, H. S. Teoh wrote: On Tue, Feb 22, 2022 at 05:25:18PM +, frame via Digitalmars-d-learn wrote: On Tuesday, 22 February 2022 at 13:25:16 UTC, bauss wrote: > Welcome to the world of auto decoding, D's million dollar > mistake. Well, I thin

Re: Odd behaviour of std.range

2022-02-22 Thread frame via Digitalmars-d-learn
On Tuesday, 22 February 2022 at 13:25:16 UTC, bauss wrote: Welcome to the world of auto decoding, D's million dollar mistake. Well, I think it's ok for strings but it shouldn't do it for simple arrays where it's intentional that I want to process the character and not a UTF-8 codepoint.

Re: Odd behaviour of std.range

2022-02-22 Thread frame via Digitalmars-d-learn
On Tuesday, 22 February 2022 at 12:53:03 UTC, Adam D Ruppe wrote: On Tuesday, 22 February 2022 at 12:48:21 UTC, frame wrote: What am I missing here? Is this some UTF conversion issue? `front` is a phobos function. Phobos treats char as special than all other arrays. Ah, ok. It directly

Odd behaviour of std.range

2022-02-22 Thread frame via Digitalmars-d-learn
What am I missing here? Is this some UTF conversion issue? ```d string a; char[] b; pragma(msg, typeof(a.take(1).front)); // dchar pragma(msg, typeof(b.take(1).front)); // dchar ```

Re: curl error msg

2022-02-20 Thread frame via Digitalmars-d-learn
On Saturday, 19 February 2022 at 13:12:32 UTC, MichaelBi wrote: when running the example in the std.net.curl on my windows, got following msg: std.net.curl.CurlException@std\net\curl.d(4239): Failed to load curl, tried "libcurl.dll", "curl.dll" does it mean i don't have those dll files?

Re: Offline D documentation/tutorial

2022-02-13 Thread frame via Digitalmars-d-learn
On Sunday, 13 February 2022 at 20:48:45 UTC, Jordi Sayol wrote: El 13/2/22 a les 12:22, frame via Digitalmars-d-learn ha escrit: On Sunday, 13 February 2022 at 00:17:26 UTC, rikki cattermole wrote: There are some files available at https://d-apt.sourceforge.io/ It would also nice to have

Re: Offline D documentation/tutorial

2022-02-13 Thread frame via Digitalmars-d-learn
On Sunday, 13 February 2022 at 00:17:26 UTC, rikki cattermole wrote: There are some files available at https://d-apt.sourceforge.io/ It would also nice to have a up-to-date CHM version of https://github.com/a11e99z/DlangChm Are there any compiled sources?

Order of object fields

2022-01-27 Thread frame via Digitalmars-d-learn
Is the order of fields guaranteed returned by `.tupleof` and `__traits(getMember,...)`, can I rely on this? I know that are different things, I mean just per each use case if I have more functions that traverses through all fields. Thx.

Re: Linkage question

2022-01-24 Thread frame via Digitalmars-d-learn
On Monday, 24 January 2022 at 18:30:02 UTC, Stanislav Blinov wrote: The difference is in how arguments are being passed, which you seem to have discovered already :) Would like to know where the linkage format is defined, thx. It should be here: https://dlang.org/spec/abi.html although

Linkage question

2022-01-24 Thread frame via Digitalmars-d-learn
If I declare a function as extern(C) inside a DLL, I have also to cast the function pointer as extern(C) or it fails calling, eg. ```d // --- my.dll export extern (C) void log(int mode, string a, string b, string c) { /* stuff */ } // --- main.d alias T = extern (C) void function(int,

Re: How to do same as 'nmap' command from within a D program?

2022-01-22 Thread frame via Digitalmars-d-learn
On Saturday, 22 January 2022 at 20:55:38 UTC, Daren Scot Wilson wrote: I don't see any D std.* libraries that do this. Are there a Dub packages I should look at? If you really want to this in D without any external app or OS API you could just ping all possible hosts, see which respond and

alias and __VERSION__ condition doesn't play well

2022-01-17 Thread frame via Digitalmars-d-learn
At the very top of my module I have this declaration: ```d static if (__VERSION__ >= 2098) { alias Foo = TypeA; } else { alias Foo = TypeB; } ``` No problem inside the module itself but this doesn't work when imported from another module: Error: undefined identifier `Foo` While this

  1   2   3   4   >