Re: Is there an easy way to convert a C header to a D module?

2021-03-14 Thread evilrat via Digitalmars-d-learn
On Monday, 15 March 2021 at 02:43:01 UTC, Tim wrote: On Monday, 15 March 2021 at 02:03:09 UTC, Adam D. Ruppe wrote: On Monday, 15 March 2021 at 01:53:31 UTC, Tim wrote: I'm needing to use a c/c++ library in a D program and I'm struggling with creating a binding as it seems like an enormous

Re: Is there an easy way to convert a C header to a D module?

2021-03-14 Thread Tim via Digitalmars-d-learn
On Monday, 15 March 2021 at 02:47:12 UTC, Adam D. Ruppe wrote: On Monday, 15 March 2021 at 02:43:01 UTC, Tim wrote: Seems pretty good. Does it work on c++ stuff too? I don't think so Bother. Well, I'm sure it will still be useful though. Thanks for the heads up

Re: Is there an easy way to convert a C header to a D module?

2021-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 15 March 2021 at 02:43:01 UTC, Tim wrote: Seems pretty good. Does it work on c++ stuff too? I don't think so

Re: Is there an easy way to convert a C header to a D module?

2021-03-14 Thread Tim via Digitalmars-d-learn
On Monday, 15 March 2021 at 02:03:09 UTC, Adam D. Ruppe wrote: On Monday, 15 March 2021 at 01:53:31 UTC, Tim wrote: I'm needing to use a c/c++ library in a D program and I'm struggling with creating a binding as it seems like an enormous amount of regex modifications. Is there an existing

Re: Is there an easy way to convert a C header to a D module?

2021-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 15 March 2021 at 01:53:31 UTC, Tim wrote: I'm needing to use a c/c++ library in a D program and I'm struggling with creating a binding as it seems like an enormous amount of regex modifications. Is there an existing program that can create most if not all of a binding for me?

Is there an easy way to convert a C header to a D module?

2021-03-14 Thread Tim via Digitalmars-d-learn
I'm needing to use a c/c++ library in a D program and I'm struggling with creating a binding as it seems like an enormous amount of regex modifications. Is there an existing program that can create most if not all of a binding for me? Thanks

How to open a compressed file in gz format ?

2021-03-14 Thread sharkloc via Digitalmars-d-learn
I want to read the content(file.gz) line by line,the following code is not friendly to large files of hundreds of Gb, and the memory overhead is also very large. import std.stdio; import std.process; import std.string; void main(string[] args){ string fileName = args[1];

Re: Forbidden file names?

2021-03-14 Thread Brian via Digitalmars-d-learn
On Sunday, 14 March 2021 at 20:57:39 UTC, Paul Backus wrote: This is the error you get when you try to call a function that has the same name as the current module. The best way to fix it is to rename the module, but if you can't, you can use an alias to disambiguate: alias sort =

Re: Forbidden file names?

2021-03-14 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 14 March 2021 at 20:47:00 UTC, Brian wrote: Hello -- Apologies if this is answered somewhere in the documentation. I was trying out the sample code on the dlang.org home page. When I got to the "Sort an Array at Compile-Time" example, I saved it on my machine as sort.d. When I

Forbidden file names?

2021-03-14 Thread Brian via Digitalmars-d-learn
Hello -- Apologies if this is answered somewhere in the documentation. I was trying out the sample code on the dlang.org home page. When I got to the "Sort an Array at Compile-Time" example, I saved it on my machine as sort.d. When I tried to build sort.d, the compile failed. But when I

Re: Workaround to "import" an exception from a DLL

2021-03-14 Thread frame via Digitalmars-d-learn
On Sunday, 14 March 2021 at 15:45:19 UTC, Imperatorn wrote: On Sunday, 14 March 2021 at 09:35:40 UTC, frame wrote: In the past I've used a two patterns which are kinda wierd but. Basically the first is returning a tuple w value and exception and just check it, kinda like Go. The second

Re: Workaround to "import" an exception from a DLL

2021-03-14 Thread frame via Digitalmars-d-learn
On Sunday, 14 March 2021 at 12:27:17 UTC, evilrat wrote: On Sunday, 14 March 2021 at 09:35:40 UTC, frame wrote: As a workaround maybe you could introduce special DLLWrapperException with reference to original exception using cast hack? This is unsatisfying. I want to switch-catch the

Re: Why are enums with base type string not considered strings?

2021-03-14 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 14 March 2021 at 16:09:39 UTC, Imperatorn wrote: On Sunday, 14 March 2021 at 10:42:17 UTC, wolframw wrote: enum BoolEnum : bool { TestBool = false } enum CharEnum : char { TestChar = 'A' } enum StringEnum : string { TestString = "Hello" } pragma(msg, isBoolean!BoolEnum);

Re: Why are enums with base type string not considered strings?

2021-03-14 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 14 March 2021 at 10:42:17 UTC, wolframw wrote: enum BoolEnum : bool { TestBool = false } enum CharEnum : char { TestChar = 'A' } enum StringEnum : string { TestString = "Hello" } pragma(msg, isBoolean!BoolEnum); // true pragma(msg, isSomeChar!CharEnum); // true

Re: Workaround to "import" an exception from a DLL

2021-03-14 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 14 March 2021 at 09:35:40 UTC, frame wrote: I know I cannot throw exceptions from a DLL, it will crash. So I currently use a wrapper that collects exceptions and pick it up if the wrapper method returns a failure state. As I know what type of exception will be thrown, I can copy

Re: Workaround to "import" an exception from a DLL

2021-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 March 2021 at 12:27:17 UTC, evilrat wrote: The problem is that TypeInfo is not shared on Windows, which is actually roots deeper in the other problems with "sharing". Unfortunately I cannot provide you with details, but this situation is well known long standing issue. It isn't

Re: How do I load dylib (i.e. phobos and druntime for ldc) in Macos sandboxed app?

2021-03-14 Thread David via Digitalmars-d-learn
On Sunday, 14 March 2021 at 11:40:25 UTC, David wrote: This is more a macos thing than a D thing but still relevant. In another thread I was asking about cleaning up a D dylib for using in Excel. Ldc was suggested though first I have to figure out how to make the phobos and druntime loadable

Re: Workaround to "import" an exception from a DLL

2021-03-14 Thread evilrat via Digitalmars-d-learn
On Sunday, 14 March 2021 at 09:35:40 UTC, frame wrote: // this returns null in the program (but works in a debugger watch): MyExceptionObj imported = cast(MyExceptionObj)e; // this actually works: MyExceptionObj imported = cast(MyExceptionObj) cast(void*)e; Is there are way to copy the

How do I load dylib (i.e. phobos and druntime for ldc) in Macos sandboxed app?

2021-03-14 Thread David via Digitalmars-d-learn
This is more a macos thing than a D thing but still relevant. In another thread I was asking about cleaning up a D dylib for using in Excel. Ldc was suggested though first I have to figure out how to make the phobos and druntime loadable from within the sandbox. (I've posted in a new topic as

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-14 Thread David via Digitalmars-d-learn
On Sunday, 14 March 2021 at 01:38:23 UTC, David Skluzacek wrote: On Thursday, 11 March 2021 at 22:10:04 UTC, David wrote: I wasn't aware that object files could be manipulated like the strip manual page - thx for the heads up. With the caveats that the linked post is almost 14 years old, I

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-14 Thread David via Digitalmars-d-learn
On Sunday, 14 March 2021 at 00:00:59 UTC, Adam D. Ruppe wrote: On Saturday, 13 March 2021 at 23:41:28 UTC, David wrote: So Excel complains that it can't load my library - presumably because libphobos2 and libdruntime are not in the sandbox.ly You *might* be able to compile with

Why are enums with base type string not considered strings?

2021-03-14 Thread wolframw via Digitalmars-d-learn
enum BoolEnum : bool { TestBool = false } enum CharEnum : char { TestChar = 'A' } enum StringEnum : string { TestString = "Hello" } pragma(msg, isBoolean!BoolEnum); // true pragma(msg, isSomeChar!CharEnum); // true pragma(msg, isSomeString!StringEnum); // false Why does

Workaround to "import" an exception from a DLL

2021-03-14 Thread frame via Digitalmars-d-learn
I know I cannot throw exceptions from a DLL, it will crash. So I currently use a wrapper that collects exceptions and pick it up if the wrapper method returns a failure state. As I know what type of exception will be thrown, I can copy all important data to a new exception object and then