Re: A strange charArray.ptr behavior

2020-12-02 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 21:01:22 UTC, Ali Çehreli wrote: On 12/2/20 12:20 PM, Ferhat Kurtulmuş wrote: given the function: export void ceaser_enc(char* input, ref char* output); this compiles:     char* sezar = (new char[65]).ptr;     ceaser_enc(key, sezar); this does not compile:

Re: My first application in Dlang

2020-12-02 Thread Marcone via Digitalmars-d-learn
On Thursday, 3 December 2020 at 02:44:40 UTC, Ali Çehreli wrote: On 12/2/20 5:46 PM, Marcone wrote: Hello, my name is Marcone, I live in Brazil, and I have been studying Dlang for a year. I finished my first application in Dlang with a graphical interface in Win32api and made it available on t

Re: My first application in Dlang

2020-12-02 Thread Ali Çehreli via Digitalmars-d-learn
On 12/2/20 5:46 PM, Marcone wrote: Hello, my name is Marcone, I live in Brazil, and I have been studying Dlang for a year. I finished my first application in Dlang with a graphical interface in Win32api and made it available on the internet for anyone who wants to download it. Here is the progr

My first application in Dlang

2020-12-02 Thread Marcone via Digitalmars-d-learn
Hello, my name is Marcone, I live in Brazil, and I have been studying Dlang for a year. I finished my first application in Dlang with a graphical interface in Win32api and made it available on the internet for anyone who wants to download it. Here is the program link. As a beginner in the D pro

Re: D Bindings for C Opaque Pointers

2020-12-02 Thread Kyle Ingraham via Digitalmars-d-learn
On Thursday, 3 December 2020 at 01:19:05 UTC, bachmeier wrote: On Thursday, 3 December 2020 at 00:30:06 UTC, Kyle Ingraham wrote: What did I do wrong in constructing the bindings? If it helps the library provides a function called EdsRelease for cleaning-up allocated objects. Is the managemen

Re: D Bindings for C Opaque Pointers

2020-12-02 Thread Kyle Ingraham via Digitalmars-d-learn
On Thursday, 3 December 2020 at 00:58:20 UTC, Paul Backus wrote: On Thursday, 3 December 2020 at 00:30:06 UTC, Kyle Ingraham wrote: // EDSDKTypes.h typedef struct __EdsObject* EdsBaseRef; typedef EdsBaseRef EdsCameraListRef; // [...] // edsdk.d struct EdsBaseRef; alias EdsBaseRef EdsCameraL

Re: D Bindings for C Opaque Pointers

2020-12-02 Thread bachmeier via Digitalmars-d-learn
On Thursday, 3 December 2020 at 00:30:06 UTC, Kyle Ingraham wrote: What did I do wrong in constructing the bindings? If it helps the library provides a function called EdsRelease for cleaning-up allocated objects. Is the management of pointers between D and C the issue? Please forgive me if I'

Re: D Bindings for C Opaque Pointers

2020-12-02 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 3 December 2020 at 00:30:06 UTC, Kyle Ingraham wrote: // EDSDKTypes.h typedef struct __EdsObject* EdsBaseRef; typedef EdsBaseRef EdsCameraListRef; // [...] // edsdk.d struct EdsBaseRef; alias EdsBaseRef EdsCameraListRef; You've dropped a level of indirection here. In the C hea

D Bindings for C Opaque Pointers

2020-12-02 Thread Kyle Ingraham via Digitalmars-d-learn
Hello all. I am new to D and loving the experience so far. I am trying to make use of a C library from Canon that provides a header and a pre-compiled binary containing implementations of declarations found in the header. I used the excellent guide at https://www.gamedev.net/articles/programmi

Re: Anybody know if I can build DMD with Visual Studio 2019?

2020-12-02 Thread WhatMeWorry via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 22:58:53 UTC, WhatMeWorry wrote: I'm trying to build DMD with Visual D under Visual Studio as shown in the Wiki: https://wiki.dlang.org/Building_under_Windows The notes say to use the solution vcbuild: You should be able to build DMD using the visual studio s

Re: A strange charArray.ptr behavior

2020-12-02 Thread Ali Çehreli via Digitalmars-d-learn
On 12/2/20 12:20 PM, Ferhat Kurtulmuş wrote: given the function: export void ceaser_enc(char* input, ref char* output); this compiles:     char* sezar = (new char[65]).ptr;     ceaser_enc(key, sezar); this does not compile:     char[] sezar = new char[65];     ceaser_enc(key, sezar.ptr);

Re: How to build dll?

2020-12-02 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 20:08:29 UTC, Jack wrote: On Wednesday, 2 December 2020 at 19:42:37 UTC, Jack wrote: D code: [...] compiled with: [...] called from: [...] but hinstLib is NULL and GetLastError() = 193: [...] What am I missing? for same reason, the dll build

A strange charArray.ptr behavior

2020-12-02 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
given the function: export void ceaser_enc(char* input, ref char* output); this compiles: char* sezar = (new char[65]).ptr; ceaser_enc(key, sezar); this does not compile: char[] sezar = new char[65]; ceaser_enc(key, sezar.ptr); by yielding: "cannot pass rvalue argument cast(ch

Re: How to build dll?

2020-12-02 Thread Jack via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 19:42:37 UTC, Jack wrote: D code: import core.sys.windows.dll; mixin SimpleDllMain; version(Windows) extern(C) export int foo() { return 42; } compiled with: dmd -ofmydll.dll -shared -m32 dll.d called from: typedef int (__cdecl *MYPROC)(void); int WINA

Re: How make Optional pre determined parameter type without overload function?

2020-12-02 Thread Marcone via Digitalmars-d-learn
Now my slice works fine. // Tipo Nulo. class None {} // Função slice() auto slice(T1, T2, T3 = None)(T1 conteudo, T2 inicio, T3 fim = T3.init) { int start, end, startlen; static if (is(T2 == int)) {inicio = inicio < 0 ? conteudo.length + inicio : inicio;} static if (is(T3 == int))

How to build dll?

2020-12-02 Thread Jack via Digitalmars-d-learn
D code: import core.sys.windows.dll; mixin SimpleDllMain; version(Windows) extern(C) export int foo() { return 42; } compiled with: dmd -ofmydll.dll -shared -m32 dll.d called from: typedef int (__cdecl *MYPROC)(void); int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,

invalid path to external symbolizer!

2020-12-02 Thread Calvin P via Digitalmars-d-learn
I try find a memory issue with ldc -betterC -g -fsanitize=address -disable-fp-elim, get invalid path to external symbolizer! Is there a way to print the symbol and line ? = ==113433==ERROR: AddressSanitizer: heap-buffer-overflow

Re: IsTuple returns true for Nullable!SomeTuple

2020-12-02 Thread Ben Jones via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 12:59:52 UTC, Paul Backus wrote: No, this is not a bug, because Nullable!T currently has an implicit conversion to T via `alias this`. [1] However, this implicit conversion is deprecated, and will be removed in a future release. Once that happens, `isTuple!NT` w

Re: ParameterIdentifierTuple returns empty strings

2020-12-02 Thread Andre Pany via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 15:40:09 UTC, Adam D. Ruppe wrote: On Wednesday, 2 December 2020 at 11:46:26 UTC, Andre Pany wrote: [...] Function pointers don't really have parameter names. They are allowed for user habit and documentation purposes, but the compiler mostly* ignores them; t

Re: ParameterIdentifierTuple returns empty strings

2020-12-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 11:46:26 UTC, Andre Pany wrote: alias fpt = extern(C) nothrow void function(int a, int b); Function pointers don't really have parameter names. They are allowed for user habit and documentation purposes, but the compiler mostly* ignores them; they aren't actua

Re: ParameterIdentifierTuple returns empty strings

2020-12-02 Thread user1234 via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 11:46:26 UTC, Andre Pany wrote: Hi, I need to retrieve the parameter identifier but only empty strings are returned: tuple("", "") ``` d alias fpt = extern(C) nothrow void function(int a, int b); void main() { import std.traits : ParameterIdentifierTuple;

Re: IsTuple returns true for Nullable!SomeTuple

2020-12-02 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 05:25:09 UTC, Ben Jones wrote: This seems like very surprising behavior to me. Is it a bug? import std.typecons; alias NT = Nullable!(Tuple!(int, double)); pragma(msg, isTuple!NT); //prints true! No, this is not a bug, because Nullable!T currently has an impl

Re: Running unit tests from DUB single file packages

2020-12-02 Thread drug via Digitalmars-d-learn
On 12/1/20 5:18 PM, Johannes Loher wrote: Am 01.12.20 um 14:55 schrieb drug: On 12/1/20 2:40 PM, Johannes Loher wrote: ... However, I am having trouble running the unit tests when using the ... This can be one of solution https://github.com/dlang/dub/pull/2050 Thanks! Let's see if it gets

ParameterIdentifierTuple returns empty strings

2020-12-02 Thread Andre Pany via Digitalmars-d-learn
Hi, I need to retrieve the parameter identifier but only empty strings are returned: tuple("", "") ``` d alias fpt = extern(C) nothrow void function(int a, int b); void main() { import std.traits : ParameterIdentifierTuple; pragma(msg, ParameterIdentifierTuple!(fpt)); } ``` Where is

Re: Dude about ~ array concatenation performance

2020-12-02 Thread ddcovery via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 06:31:49 UTC, H. S. Teoh wrote: On Tue, Dec 01, 2020 at 10:49:55PM +, ddcovery via Digitalmars-d-learn wrote: Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! [...] With