Re: ImportC: Windows.h

2023-12-02 Thread name via Digitalmars-d-learn
On Saturday, 2 December 2023 at 08:36:01 UTC, Stefan Koch wrote: On Saturday, 2 December 2023 at 05:16:43 UTC, name wrote: Minimum thing to reproduce bug: [...] It doesn't show up since it's defined as an Identifier Expression which cannot be resolved. But why can't it be resolved?

Re: ImportC: Windows.h

2023-12-02 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 2 December 2023 at 05:16:43 UTC, name wrote: Minimum thing to reproduce bug: main.d: ```d import test; void main() { auto a = FILE_MAP_READ; } ``` test.c ```c #define SECTION_MAP_READ 0x0004 #define FILE_MAP_READ SECTION_MAP_READ ``` build with

Re: ImportC: Windows.h

2023-12-01 Thread name via Digitalmars-d-learn
Minimum thing to reproduce bug: main.d: ```d import test; void main() { auto a = FILE_MAP_READ; } ``` test.c ```c #define SECTION_MAP_READ 0x0004 #define FILE_MAP_READ SECTION_MAP_READ ``` build with ```"D:\dmd.2.105.3.windows\dmd2\windows\bin64\dmd.exe" -c test.c -vcg-ast```.

Re: ImportC: Windows.h

2023-12-01 Thread name via Digitalmars-d-learn
On Friday, 1 December 2023 at 10:23:08 UTC, Kagamin wrote: In C macros can be defined to any expression, so ImportC interprets these parentheses as arbitrary expression macros and skips them thinking they are helper macros that can't be always translated. But does that explain why using

Re: ImportC: Windows.h

2023-12-01 Thread name via Digitalmars-d-learn
So, uh, I tried deleting the parens off GENERIC_READ's value: winnt.h: ```c // // These are the generic rights. // #define GENERIC_READ 0x8000L #define GENERIC_WRITE(0x4000L) #define GENERIC_EXECUTE (0x2000L) #define

Re: ImportC: Windows.h

2023-12-01 Thread name via Digitalmars-d-learn
On Friday, 1 December 2023 at 08:45:30 UTC, Kagamin wrote: Is GENERIC_WRITE awailable? No, it's not. I tried building with LDC 1.35.0: ```"D:\ldc2-1.35.0-windows-x64\bin\ldc2.exe" main.d -i -vcg-ast```. winnt.h: ```c // begin_wdm // begin_ntoshvp typedef DWORD ACCESS_MASK; typedef

Re: ImportC: Windows.h

2023-12-01 Thread Kagamin via Digitalmars-d-learn
Is GENERIC_WRITE awailable?

Re: ImportC: Windows.h

2023-11-30 Thread name via Digitalmars-d-learn
Weird... building with ```dmd -m64 -i main.d``` works fine. Then, I tried calling [CreateFileW](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew), passing ```GENERIC_READ``` for ```[in] dwDesiredAccess```; I get this: ```main.d(7): Error: undefined identifier

Re: ImportC: Windows.h

2023-11-30 Thread name via Digitalmars-d-learn
On Thursday, 30 November 2023 at 08:54:40 UTC, Kagamin wrote: You can declare them ``` extern(C) void _InterlockedExchangeAdd(){ assert(false); } ``` That works, thanks.

Re: ImportC: Windows.h

2023-11-30 Thread Kagamin via Digitalmars-d-learn
You can declare them ``` extern(C) void _InterlockedExchangeAdd(){ assert(false); } ```