ldc wasm multi-memory import-memory support?

2025-02-14 Thread Dakota via Digitalmars-d-learn
clang suport multi-memory with flags `--wasm-features=multi-memory`, is LDC support `multi-memory` without c code?

Re: translate alias align from C to D

2025-01-13 Thread Dakota via Digitalmars-d-learn
On Monday, 13 January 2025 at 14:52:05 UTC, Matheus Catarino wrote: On Monday, 13 January 2025 at 11:36:45 UTC, Dakota wrote: You could simply use dstep or dmd/ldc2 `-H`|`-Hf=`. Thanks for tips. My point is c allot align to alias, is D support it ? I want avoid importC, because I want to w

translate alias align from C to D

2025-01-13 Thread Dakota via Digitalmars-d-learn
```c #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) # include #endif #if defined(_MSC_VER) /* do not use alignment for older visual studio versions */ # if _MSC_VER < 1913 /* Visual Studio 2017 version 15.6 */ #define CGLM_ALL_UNALIGNED #define CGLM_ALIGN(X) /* no alig

Re: Is there a way to Deferred binding symbol from dynamic library?

2024-11-26 Thread Dakota via Digitalmars-d-learn
On Saturday, 23 November 2024 at 12:09:22 UTC, IchorDev wrote: Why not load the libraries at runtime and look the pointers up with symbol names? Or do you really need the compiler to do it for you? Thanks for suggestion. Because I need link some part static c library, they link global var

Is there a way to Deferred binding symbol from dynamic library?

2024-11-21 Thread Dakota via Digitalmars-d-learn
Try build a dynamic library, a lot function symbol and global symbol need to be deferred binding from runtime app. It can be done by pass `-Wl,-undefined,dynamic_lookup` or `--unresolved-symbols=dynamic_lookup` to linker. I am look a way to do it from d code, like `pragma(linkerDirective,

Re: I can not understand this Error: undefined identifier `cpp_longlong`

2024-11-20 Thread Dakota via Digitalmars-d-learn
On Wednesday, 20 November 2024 at 07:02:25 UTC, Dakota wrote: I am sure it defined because I add static assert to confirm this `config.d`: and not sure how to work this around: ```sh #0 0x000103d4e8f7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/ldc/bin/ldc2+0x1038098f7) #1

I can not understand this Error: undefined identifier `cpp_longlong`

2024-11-19 Thread Dakota via Digitalmars-d-learn
```sh /ldc/import/core/stdc/stdint.d(96): Error: undefined identifier `cpp_longlong` /ldc/import/core/stdc/stdint.d(97): Error: undefined identifier `cpp_ulonglong` /ldc/import/core/stdc/stdint.d(118): Error: undefined identifier `cpp_ulong` ``` I am sure it defined because I add static asser

Re: need help to find a way to replace c macro

2024-10-17 Thread Dakota via Digitalmars-d-learn
On Tuesday, 15 October 2024 at 15:29:09 UTC, ryuukk_ wrote: [...] Thanks very much.

is there sigjmp_buf for Darwin?

2024-10-16 Thread Dakota via Digitalmars-d-learn
seems not able to import sigjmp_buf for macOS.

Re: need help to find a way to replace c macro

2024-10-15 Thread Dakota via Digitalmars-d-learn
On Tuesday, 15 October 2024 at 12:13:36 UTC, monkyyy wrote: Your probably going to need to simplify that block of code looks awful source code here: https://github.com/bellard/quickjs/blob/master/quickjs.h#L1045

need help to find a way to replace c macro

2024-10-15 Thread Dakota via Digitalmars-d-learn
```c typedef union JSCFunctionType { JSCFunction *generic; JSValue (*generic_magic)(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic); JSCFunction *constructor; JSValue (*constructor_magic)(JSContext *ctx, JSValueConst new_target, int argc, JSValueC

Re: need help to redefine packed c struct in d

2024-09-28 Thread Dakota via Digitalmars-d-learn
On Saturday, 28 September 2024 at 08:35:39 UTC, Johan wrote: On Saturday, 28 September 2024 at 07:54:40 UTC, Dakota wrote: ```c struct __attribute__((packed)) type1 { uint32_tu32; uint8_t u8; uint16_tu16a; uint16_tu16b; uint8_t u8a;

Re: need help to work around float union non-zero init

2024-09-23 Thread Dakota via Digitalmars-d-learn
On Friday, 20 September 2024 at 16:21:10 UTC, Nick Treleaven wrote: On Friday, 20 September 2024 at 09:38:54 UTC, Dakota wrote: Thanks to Dennis for the workaround. Thanks your all for the tips, void solution fix me problem.

need help to work around float union non-zero init

2024-09-20 Thread Dakota via Digitalmars-d-learn
I need my struct defined as `isZeroInit`, so can I can import them as `di` file. (this also reduce build size) But I find this problem with float inside union: ```d struct test_t { union { int i32; float f32; } } static assert(__traits(isZeroInit, test_t) ); ``` ``

Re: need help to use Emscripten with LDC to build wasm projects

2024-08-22 Thread Dakota via Digitalmars-d-learn
On Thursday, 22 August 2024 at 21:19:57 UTC, monkyyy wrote: On Thursday, 22 August 2024 at 07:28:00 UTC, Dakota wrote: Is there a way to link ldc objects with Emscripten to build wasm binary ? yes; you'll have to untangle my build system https://github.com/crazymonkyyy/raylib-2024 It will al

Re: inportC with postgres 16_4 on macOS error

2024-08-08 Thread Dakota via Digitalmars-d-learn
On Thursday, 8 August 2024 at 10:08:18 UTC, Dakota wrote: dmd v2.110.0-beta.1 ```c #if defined(_DARWIN_UNLIMITED_STREAMS) || defined(_DARWIN_C_SOURCE) FILE*fopen(const char * __restrict __filename, const char * __restrict __mode) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_3_2, __DAR

inportC with postgres 16_4 on macOS error

2024-08-08 Thread Dakota via Digitalmars-d-learn
dmd v2.110.0-beta.1 ```sh /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h(145): Error: found `__filename` when expecting `,` /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/inc

importC error: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/vm_types.h(168): Error: variable `lib_test.mach_vm_range_recipe_v1_t.ra

2024-08-07 Thread Dakota via Digitalmars-d-learn
```sh /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/vm_types.h(168): Error: variable `lib_test.mach_vm_range_recipe_v1_t.range` - no definition of struct `mach_vm_range` /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.

importC error: alignment value expected, not `sizeof`

2024-08-07 Thread Dakota via Digitalmars-d-learn
```c typedef struct test_s { unsigned char _[64] __attribute__ ((aligned (sizeof (void *; } test_t; ```

Re: importC with struct name and function conflict

2024-08-05 Thread Dakota via Digitalmars-d-learn
On Monday, 5 August 2024 at 11:35:56 UTC, Dennis wrote: On Monday, 5 August 2024 at 11:02:24 UTC, Dakota wrote: This will not work for me. (huge code base I can not change and maintain) You don't have to change the code where the type is defined per se, you just need to put it in any C file

Re: importC with struct name and function conflict

2024-08-05 Thread Dakota via Digitalmars-d-learn
On Saturday, 3 August 2024 at 11:55:53 UTC, Dennis wrote: On Saturday, 3 August 2024 at 05:10:37 UTC, Dakota wrote: How can I get the function and type from importC? is there a auto rename mechanism ? The most pragmatic workaround is to add a typedef to the C code: ```C int S; struct S { int

importC with struct name and function conflict

2024-08-02 Thread Dakota via Digitalmars-d-learn
```c struct type_name { int a; } int type_name(int a); ``` How can I get the function and type from importC? is there a auto rename mechanism ?

importC error: can not find the #define ERR_INVALID -1

2024-08-02 Thread Dakota via Digitalmars-d-learn
```c #define ERR_SUCCESS 0 #define ERR_INVALID -1 // invalid argument ``` If the number >=0, it work. < 0 will not work. DMD64 D Compiler v2.110.0-beta.1

Error: circular reference to variable cause by order (bugs?)

2024-07-18 Thread Dakota via Digitalmars-d-learn
I am trying to translate some c code into d, get this error: ```d struct A { void* sub; } struct B { void* subs; } __gshared { const A[1] a0 = [ { &b1_ptr }, ]; const A[2] a1 = [ { &b1_ptr }, ]; const B b1 =

Re: need help to check symbol is static variable or not

2024-07-15 Thread Dakota via Digitalmars-d-learn
On Monday, 15 July 2024 at 11:16:23 UTC, Nick Treleaven wrote: I put `type_s` in a file anonstruct.c, then: ```d import anonstruct; pragma(msg, isStatic!(type_s.c)); ``` That outputs `false`, because the symbol is not a compile-time value. Is that what you meant? No, I am here deal with a lo

Re: need help to check symbol is static variable or not

2024-07-14 Thread Dakota via Digitalmars-d-learn
On Monday, 1 July 2024 at 11:15:46 UTC, Nick Treleaven wrote: ``` There is a case check will give wrong resutls: ```d struct type_s { union { struct { int a; int b; } c; }; }; ``` `type c` will return false with `enum isStatic(alias V

Re: need help to get bitoffsetof bitwidth for clang

2024-07-04 Thread Dakota via Digitalmars-d-learn
On Wednesday, 3 July 2024 at 21:47:32 UTC, Tim wrote: If you only want to see the layout, you can use the following command to dump it: ``` clang test.c -Xclang -fdump-record-layouts -c ``` File test.c could contain the following: ``` struct S { int a : 3; int b : 29; }; struct S dummy;

Re: need help to check symbol is static variable or not

2024-07-01 Thread Dakota via Digitalmars-d-learn
On Monday, 1 July 2024 at 11:15:46 UTC, Nick Treleaven wrote: On Monday, 1 July 2024 at 07:32:30 UTC, Dakota wrote: this code give error: ```d static if( !__traits(compiles, mixin("enum v = V;")) ) { enum v = V; } ``` __traits(compiles, ...) can't check if a declaration is valid directl

need help to check symbol is static variable or not

2024-07-01 Thread Dakota via Digitalmars-d-learn
this code give error: ```d static if( !__traits(compiles, mixin("enum v = V;")) ) { enum v = V; } ``` ```sh Error: static variable `NotWorkVar` cannot be read at compile time ``` V is alias get from `typeof(__traits(getMember, M, symbol)`, M is `module` from importC. the importC so

Re: need help to use C++ callback from garnet

2024-06-04 Thread Dakota via Digitalmars-d-learn
On Wednesday, 29 May 2024 at 09:01:13 UTC, evilrat wrote: On Wednesday, 29 May 2024 at 07:47:01 UTC, Dakota wrote: [...] (here is the signature of callback) https://github.com/microsoft/garnet/blob/ade2991f3737b9b5e3151d0dd0b614adfd4bcecd/libs/storage/Tsavorite/cc/src/device/async.h#L25 [...

need help to use C++ callback from garnet

2024-05-29 Thread Dakota via Digitalmars-d-learn
I try use https://github.com/microsoft/garnet/blob/main/libs/storage/Tsavorite/cc/src/device/native_device_wrapper.cc from D Not sure how to make this work with D: ```c++ EXPORTED_SYMBOL FASTER::core::Status NativeDevice_ReadAsync(NativeDevice* device, uint64_t source, void* dest, uint32_t

question about ctfe init importC zero length array of struct

2024-02-28 Thread Dakota via Digitalmars-d-learn
This is the type defined from c code import by importC: ```c struct A { int count; int[] i; } ``` This kind data need to be init as const to avoid runtime cost, and need to be done from D code. how can I do this ? To put code into D source, I can use "-i=package" to automatically

Re: need help with simple importC

2024-02-26 Thread Dakota via Digitalmars-d-learn
On Monday, 26 February 2024 at 07:44:02 UTC, Dakota wrote: I am use importC from linux, get this error: ```sh /usr/include/x86_64-linux-gnu/bits/floatn-common.h(214): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/floatn-common.h(251): Error: illegal combinat

Re: importC with gc-sections not work on linux

2024-02-26 Thread Dakota via Digitalmars-d-learn
On Monday, 26 February 2024 at 12:33:02 UTC, Richard (Rikki) Andrew Cattermole wrote: On 27/02/2024 1:28 AM, Dakota wrote: When I use importC to build a c library, there is a lot unused symbol missing. I try add `-L--gc-sections` to dmd to workaround this issue. This removes symbols, not kee

importC with gc-sections not work on linux

2024-02-26 Thread Dakota via Digitalmars-d-learn
When I use importC to build a c library, there is a lot unused symbol missing. I try add `-L--gc-sections` to dmd to workaround this issue. I also try `-L-dead_strip` on macOS, it work as expected. I do some google, some one suggestion use with `-ffunction-sections`, `-f fdata-sections`, d

Re: importC error Error: undefined identifier `__builtin_unreachable`

2024-02-26 Thread Dakota via Digitalmars-d-learn
On Monday, 26 February 2024 at 08:18:53 UTC, Richard (Rikki) Andrew Cattermole wrote: On 26/02/2024 9:04 PM, Dakota wrote: I try one more importC case, get this error: ```sh Error: undefined identifier `__builtin_unreachable` ``` any tips to fix this? Reported: https://issues.dlang.org/show

importC error Error: undefined identifier `__builtin_unreachable`

2024-02-26 Thread Dakota via Digitalmars-d-learn
I try one more importC case, get this error: ```sh Error: undefined identifier `__builtin_unreachable` ``` any tips to fix this?