Skip to content

Instantly share code, notes, and snippets.

@mmmunk
Created September 26, 2016 09:30
Embed
What would you like to do?
Freestanding MinGW
// Freestanding with MinGW:
// http://nullprogram.com/blog/2016/01/31/
// http://nullprogram.com/blog/2016/02/28/
// https://support.microsoft.com/da-dk/kb/99456
#include <windows.h>
int WINAPI mainCRTStartup(void)
{
char msg[] = "Hello, world!\n";
HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE);
WriteFile(stdout, msg, sizeof(msg), (DWORD[]){0}, NULL);
return 0;
}
/*
Compile:
gcc -nostdlib -ffreestanding -mconsole -O2 -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -o freestanding_hello.exe freestanding_hello.c -lkernel32
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment