pleroma.debian.social

pleroma.debian.social

Can you compile 's notepad.exe for ?

Time to waste more of my valuable limited heartbeats and keystrokes.

I've only seen one prompt for Copilot so far.

VS2026's "Create a project from existing code" window. I've got C:\git\notepad selected.

It would have been too easy if it had compiled in one go, but here's where I run into a problem:

I don't actually code C and I have no idea what the fuck I'm doing.

There's an annoying "✨Fix" button now when I right click, but I can just pester the Fediverse instead of paying for an LLM and compromising my integrity.

Deselected warnings, here's just the errors from trying to compile WINE's notepad on Windows.

Error	C2057	expected constant expression	notepad	C:\git\notepad\dialog.c	104	

Error	C2466	cannot allocate an array of constant size 0	notepad	C:\git\notepad\dialog.c	104

Error	C2133	'szCaption': unknown size	notepad	C:\git\notepad\dialog.c	104

git grep "define ARRAY_SIZE" got me to tools/tools.h:#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) in the Wine source code, so like any good coder we're going to blindly copy and paste this while having no idea what the fuck that means.

It got worse. I'm not sure if I am more afraid of C errors or resource file errors. I have never understood resource files.

Too many "invalid accelerator" errors, all in notepad.rc

Commented out the accelerators for now (bookmarking https://learn.microsoft.com/en-us/windows/win32/menurc/about-resource-files for later)

Got to my least favourite errors ever: unresolved external symbol. Thankfully I am marginally smarter than I was 10-15 years ago.

I know what WINE's Makefile uses and I can add those same references in.

various LNK2019 unresolved external symbol errors

Except they're already there?

I'm missing commctrl.h somehow

OK, is wdm.h in the Windows SDK or DDK?

WINE's notepad is using RtlUshortByteSwap and I am too impatient to keep following the documentation at https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/

I think I will just yoink WINE's implementation.

git grep "static.*RtlUshortByteSwap("
dlls/wineps.drv/type1.c:static inline WORD get_be_word(const void *p) { return RtlUshortByteSwap(*(const WORD*)p); }
include/winternl.h:static inline USHORT RtlUshortByteSwap(USHORT s)

(I don't know how to do the code formatting I see around the Fediverse)

That's all this is?

/* These are implemented as __fastcall, so we can't let Winelib apps link with them.
* Moreover, they're always inlined and not exported on 64bit systems.
*/
static inline USHORT RtlUshortByteSwap(USHORT s)
{
return (s >> 8) | (s << 8);
}

Holy fucking bingle it worked

WINE notepad under Windows 11, showing Notepad and the Windows (Win32?) "about" box.

It shows the Wine Notepad icon and that Wine Notepad is running under Windows 11 Version 25H2.

Holy fucking bingle

@voltagex
It's a standard trick to get the number of elements in an array:

sizeof(x) returns the allocated memory for the whole of the array. If your array has 10 elements and an element is a 32-bit int, then it returns 10 (elements) times 4 (bytes in a 32-bit int) = 40

sizeof(x[0]) dereferences the array to get the size of the first element. So in the same example, you get back 4.

Dividing 40 by 4 yields 10, the number of elements
replies
1
announces
0
likes
0

@voltagex
This only works for arrays allocated on the stack, not for a pointer to a 40-byte region, as for that sizeof(x) returns the size of the pointer, which is a constant that has nothing to do with the size of your array.

I'm sure you didn't need to know any of that, but now you do 😂