turdus wrote:No such thing "subset of C". The full definition is so small there's no point in defining subsets, also any subset would be insufficient.
The full definition - in form of document ISO/IEC 9899:1999 (E) - has 162 pages of normative text in chapter 1-6...
That is
excluding the library (chapter 7) and the normative Annexes.
1. precompiler directives: #include, #define, #undef, #if, #else, #endif, #pragma, #line, #error
2. keywords: auto, break, case, char, const, continue, default, do, double, else, enum, extern, float, for, goto, if, int, long, register, return, short, signed, sizeof, static, struct, switch, typedef, union, unsigned, void, volatile, while.
Since you missed #ifdef, #ifndef, inline, restrict, _Bool, _Complex and _Imaginary, I assume that your statement is based in C89.
But the current standard is C99, and by the time you are nearing completion of your C compiler, C1X will be a reality.
Let's have a look at the current draft, should we?
- Specifiers: _Alignas, _Noreturn, _Generic, _Thread_local, _Atomic
- Operators: alignof
- char16_t, char32_t, u, U and u8 string literal prefixes (i.e., full Unicode support)
- Bounds-checking interfaces (Annex K)
- Analyzability features (Annex L)
- Anonymous structures and unions
- Static assertions
You know how many fully compliant C99 compilers are out there? MSVC isn't, and GCC isn't either. Intel CC isn't, Watcom isn't, IBM VACPP isn't. All of these would
love to just slap that "C99 compliant" sticker on their advertising, but they also realized that getting there requires
serious amounts of work.
Microsoft, at least,
openly admitted that they don't plan on supporting C99 ten years after the fact.
Do not forget, that Dennis Ritchie designed it to be portable, and to achieve this it had to be minimalistic.
What Ritchie designed and what it is today is several decades, two major standardizations and several minor updates apart. You remember K&R declarations? They aren't even legal anymore.
It's not an accident that C is the longest living, and most ported language.
Yea, and most ports aren't complete, because
starting a C compiler (or any project, actually) is easy.
Finishing one to the satisfaction of professionals so that it will be called "compliant" is the tricky part. I've seen many a C lib that was begun, and swamped as implementors realized it wasn't
that easy. And getting that compiler to comply is even harder.
And I haven't talked about optimizations. GCC's -O1 includes 30 different optimizations, -O2 has 33 more, -O3 another 6, for a grand total of 69 options. Some of these are pretty involved, as you can read in the
relevant section of the manual. And with all that work, GCC generated code is not even
near the output of ICC or VACPP.
You may shrug it off, but that kind of optimization
matters in the business.
Again, patching together a somewhat-C-ish compiler with Flex and Bison is easy. Not as easy as writing a 1:1 assembler-to-machine-code translator, but easy. But it's only the first step on a
long road.