Factsheet
Using GCC to compile C code - Stack Overflow
compiler - Isn't there a chicken-and-egg issue since GCC is written in C++ itself? - Software Engineering Stack Exchange
Why is GCC the only compiler that cares deeply about C?
How to compile C++ code using GCC C compiler? - Programming & Development - Spiceworks Community
Videos
Try to compile your code normally as
gcc test.c
If you get default output file a.exe,then go for
gcc test.c -o test.exe
I would suggest you go through this compilation instruction :-
gcc -o test.exe test.c
I believe this code runs perfectly on your windows system.Please inform if it doesn't!
This is actually a well-known concept called bootstrapping. Basically, there exists, somewhere, a minimal C codebase to build a version of GCC that's capable of building the current GCC codebase. Self-hosting languages have been doing things like that for decades.
Creating a compiler that is written in the same language that it compiles is called bootstrapping. The wikipedia article describes a number of ways that a compiler can be bootstrapped.
Given your restriction that you only have a post-4.8 G++ source code and no pre-built binaries for your target platform (no existing C++ compiler), then bootstrapping the G++ compiler can be done by means of cross-compilation.
When bootstrapping a compiler using cross-compilation, you build several versions of your compiler
- On your PC, you install a C++ compiler (can be any C++ compiler, doesn't have to be G++)
- Using that compiler, you create a G++ cross-compiler that can execute on the PC and generates code for the target platform
- Using the G++ cross-compiler you just built, you create a native G++ compiler that can run on the target platform and create code for it.
- You are done. You have created a C++ compiler for the new platform.
If you also don't have a PC (or similar) to perform the initial steps on, then you are indeed stuck, but the chance of being in that situation and trying to bootstrap a compiler are negligible.
From what I've seen both Clang and MSVC lack several C features from many different versions, while GCC has almost all of them. This isn't the case with C++ where the three compilers have a very similar amount of features inside their pockets.
This makes me feel like I'm forced to use GCC if I wanna everything in C. Btw, I'm on Windows 10.