What is the maximum memory available to a C++ application on 32-bit Windows?

It will cause a dynamic memory allocation failure, which usually will make the resultant application crash, but technically, an application could be written to withstand this event. 2GB is indeed the user address space size for an individual process- an application may use multiple processes (easiest example: Chrome). If an application asks for 100MB of … Read more

Size of pid_t, uid_t, gid_t on Linux

#include <stdio.h> #include <sys/types.h> int main() { printf(“pid_t: %zu\n”, sizeof(pid_t)); printf(“uid_t: %zu\n”, sizeof(uid_t)); printf(“gid_t: %zu\n”, sizeof(gid_t)); } EDIT: Per popular request (and because, realistically, 99% of the people coming to this question are going to be running x86 or x86_64)… On an i686 and x86_64 (so, 32-bit and 64-bit) processor running Linux >= 3.0.0, the … Read more

How do I compile and link a 32-bit Windows executable using mingw-w64

That depends on which variant of toolchain you’re currently using. Both DWARF and SEH variants (which come starting from GCC 4.8.0) are only single-target. You can see it yourself by inspecting the directory structure of their distributions, i.e. they contain only the libraries with either 64- or 32-bit addressing, but not both. On the other … Read more

How to Compile 32-bit Apps on 64-bit Ubuntu?

This is known to work on Ubuntu 16.04 through 22.04: sudo apt install gcc-multilib g++-multilib Then a minimal hello world: main.c #include <stdio.h> int main(void) { puts(“hello world”); return 0; } compiles without warning with: gcc -m32 -ggdb3 -O0 -pedantic-errors -std=c89 \ -Wall -Wextra -pedantic -o main.out main.c And ./main.out outputs: hello world And: file … Read more

SetWindowsHookEx failing in .NET 4.0 on 32-bit machine with “module not found”?

Yup, I think you understand what’s going on. SetWindowsHookEx() requires a valid module handle, and verifies it, but it doesn’t actually use it when you set a low-level hook. You just need a valid handle, it doesn’t matter which specific one. Calling LoadLibrary(“user32.dll”) is a good way to get a handle, that DLL will always … Read more