Created
September 26, 2016 09:30
-
-
Save mmmunk/d0b0ed49eee3b7502da3a8db8f1dcf61 to your computer and use it in GitHub Desktop.
Freestanding MinGW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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