Re: "Error: no property `offsetof` for type `char*`"

2022-08-19 Thread MyNameHere via Digitalmars-d-learn

On Friday, 19 August 2022 at 14:30:50 UTC, kinke wrote:
Oh and `DevicePath()` is a convenience member returning a 
pointer to the 'dynamic array' (as the array decays to a 
pointer in C too), so no need to fiddle with `.offsetof` and 
computing the pointer manually.


I am using ```-BetterC```, so that path is closed to me, I think.




Re: "Error: no property `offsetof` for type `char*`"

2022-08-19 Thread MyNameHere via Digitalmars-d-learn
Thank you, that seems to have resolved the issue, though I wish 
these sorts of problems would stop cropping up, they are souring 
the experience with the language.


"Error: no property `offsetof` for type `char*`"

2022-08-19 Thread MyNameHere via Digitalmars-d-learn

I am receiving this error:

```
Error: no property `offsetof` for type `char*`
```

from this snippet:

```d
import core.sys.windows.setupapi;

void main() {
SP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetail;
uint Offset = DeviceInterfaceDetail.DevicePath.offsetof;
}
```

You may try this at https://run.dlang.io/, build with ```LDC```, 
with argument: ```-mtriple=x86_64-windows-msvc```.


Re: BetterC Name Mangling Linker Errors

2022-07-27 Thread MyNameHere via Digitalmars-d-learn

Thank you, that seems to have been the source of the error.




BetterC Name Mangling Linker Errors

2022-07-27 Thread MyNameHere via Digitalmars-d-learn

I have included the source to a simple 64-bit Windows program.
It compiles and runs fine with ```dmd -m64 
-L="/Subsystem:Windows" -L="/Entry:Main" Main.d```. But compiling 
with ```-betterC``` using the following throws up a linker error, 
```dmd -m64 -betterC -L="/Subsystem:Windows" -L="/Entry:Main" 
Main.d```:


```Main.obj : error LNK2019: unresolved external symbol 
_D4core3sys7windows7winuser11WNDCLASSEXA6__initZ referenced in 
function Main```


And I'm not sure why.

```d
import core.sys.windows.winuser;
import core.sys.windows.winbase;

pragma(lib, "User32.lib");
pragma(lib, "Kernel32.lib");

extern(Windows)
void Main(void* Instance)
{
WNDCLASSEXA WindowClass;
with (WindowClass)
{
cbSize= WindowClass.sizeof;
lpfnWndProc   = &WindowProc;
hInstance = Instance;
hCursor   = LoadCursor(null, IDC_ARROW);
lpszClassName = "Window";
}
RegisterClassExA(&WindowClass);
void *WindowHandle = CreateWindowExA(0,
 "Window",
 "Window",
 WS_OVERLAPPEDWINDOW,
 CW_USEDEFAULT,
 CW_USEDEFAULT,
 CW_USEDEFAULT,
 CW_USEDEFAULT,
 null,
 null,
 Instance,
 null);
ShowWindow(WindowHandle, SW_MAXIMIZE);

MSG Message;
while (GetMessage(&Message, null, 0, 0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
}

extern(Windows)
long WindowProc(void* WindowHandle, uint Message, ulong WParam, 
long LParam) nothrow @system

{
if (Message == WM_DESTROY) ExitProcess(0);

return DefWindowProcA(WindowHandle, Message, WParam, LParam);
}
```