Skip to content

Instantly share code, notes, and snippets.

@mmmunk
Created September 26, 2016 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmmunk/d0b0ed49eee3b7502da3a8db8f1dcf61 to your computer and use it in GitHub Desktop.
Save mmmunk/d0b0ed49eee3b7502da3a8db8f1dcf61 to your computer and use it in GitHub Desktop.
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