Re: Bind C++ template specialized with void parameter

2024-02-29 Thread DUser via Digitalmars-d-learn
On Wednesday, 28 February 2024 at 22:48:33 UTC, Gregor Mückl 
wrote:

...
But how can I bind Wrapper\ in D? Specifically, how do I 
even express that template specialization in D syntax?


Did you mean any of these?

1. Parameter specialization:
```d
extern(C++, class):
class Wrapper(T) {...}
class Wrapper(T : void) {...}
```
2. Template constraints:
```d
extern(C++, class):
class Wrapper(T) if(!is(T == void)) {...}
class Wrapper(T) if(is(T == void)) {...}
```
3. `static if`:
```d
extern(C++, class)
class Wrapper(T) {
  static if (!is(T == void))
private T t;
  private bool valid;
  public final isValid();
}
```


Re: Missing library dependencies compiling app with importC

2024-02-25 Thread DUser via Digitalmars-d-learn

On Sunday, 25 February 2024 at 13:36:43 UTC, ptcute wrote:

Thank you for the help.

I tried to modify the curl.h header exactly followinging the 
above information and with the above mentioned simple curl 
demo,unfortunately the error message are the same.


Did you remove the "#include " directive from your 
wrapper module?


Re: Missing library dependencies compiling app with importC

2024-02-25 Thread DUser via Digitalmars-d-learn

On Thursday, 22 February 2024 at 01:23:36 UTC, ptcute wrote:

...
So what's the real issue behind?

Anyone help on this would be appreciated.


They are MSVC compiler intrinsics. 
(https://issues.dlang.org/show_bug.cgi?id=23894)


Surprisingly I got it working by just replacing some includes 
with definitions in "curl/curl.h".


Change:

```c
#if defined(_WIN32) && !defined(_WIN32_WCE) && 
!defined(__CYGWIN__)

#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H) || \
  defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H))
/* The check above prevents the winsock2 inclusion if winsock.h 
already was

   included, since they can't co-exist without problems */
#include 
#include 
#endif
#endif
```
to:
```c
#if defined(_WIN32) && !defined(_WIN32_WCE) && 
!defined(__CYGWIN__)

#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H) || \
  defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H))
typedef unsigned short  u_short;
typedef unsigned intu_int;

typedef struct sockaddr {
#if (_WIN32_WINNT < 0x0600)
u_short sa_family;
#else
ADDRESS_FAMILY sa_family;   // Address family.
#endif //(_WIN32_WINNT < 0x0600)
char sa_data[14];   // Up to 14 bytes of 
direct address.

} SOCKADDR;

#if(_WIN32_WINNT >= 0x0501)
typedef unsigned __int64 u_int64;
#endif //(_WIN32_WINNT >= 0x0501)

#if  defined(_WIN64)
typedef unsigned __int64 SOCKET;
#else
typedef unsigned int SOCKET;
#endif

#ifndef FD_SETSIZE
#define FD_SETSIZE  64
#endif /* FD_SETSIZE */

typedef struct fd_set {
u_int fd_count;   /* how many are SET? */
SOCKET  fd_array[FD_SETSIZE];   /* an array of SOCKETs */
} fd_set;
#endif
#endif
```
At least this example program 
(https://curl.se/libcurl/c/getinfo.html) works fine.


Re: Is this Windows Win32 fileapi.h header accessible in D language?

2022-02-08 Thread duser via Digitalmars-d-learn

On Tuesday, 8 February 2022 at 16:10:19 UTC, BoQsc wrote:
Unsure where to start, so I decided to ask here how to get use 
of this win32 header.


https://docs.microsoft.com/en-us/windows/win32/api/fileapi/


the specific module containing that is `core.sys.windows.winbase`

my trick to find these is to use github search with the function 
you want:


  https://github.com/dlang/druntime/search?q=AreFileApisANSI


Re: Linkage question

2022-01-24 Thread duser via Digitalmars-d-learn

On Monday, 24 January 2022 at 19:41:30 UTC, frame wrote:
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 
IIRC it might not be 100% up to date.


Ah, yes. Thanks. Maybe I should read it more carefully =)

It claims that the D calling convention matches C. But it seems 
that the arguments are pushed in order whereas C does it in 
reverse order and the -218697648 value is indeed my 3rd string 
pointer.


that's a bug with dmd or the spec, arguments are currently passed 
in reverse order compared to C on 64-bit even though they should 
be the same


see:
https://issues.dlang.org/show_bug.cgi?id=20204
https://github.com/dlang/dmd/pull/13287
https://github.com/dlang/dlang.org/pull/3120