2019-10-20 - Pedantic
-------------------------------------------------------------------
Today i was reading a bit about GCC and all the compiler options it
has. And with all that i was reading, i was playing around a bit
with a little C program i made earlier.
I was mostly figuring/wondering to which standard/style my C
programming would conform to. I think i was mostly adhering to the
C99 standard, but i think i was writing a bit of a mishmash of
everything.
So as a small exercise, i turned on the -ansi or -std=c90 and the
-pedantic flags of GCC, and tried to recompile. This resulted in
some compiler errors and warnings, mostly caused by the following:
- Commenting using //comments.
- Mixing declarations and code. In ansi C, declarations are
placed at the top of a block/function.
- Combining declaration and initializations; int x=0;
And that was pretty much all of it... My program was of course
pretty simple.
Anyhow, despite following old standards this way, at least i am
following some standard, and don't mix up three different things.
I'll continue reading about more GCC stuff. But at the same time i
wonder if i can also find a good smaller/lightweight C-only
compiler. Maybe Tcc by Fabrice Bellard?