Sqlite on C99/C11 (was: RE: BUG: Illegal initialization in icu.c : sqlite3IcuInit)
From: sqlite-users [mailto:[hidden email]] On Behalf Of James K. Lowden
>>>> Basing source on "ANSI C" (as much as possible) just gives you the
>>>> biggest possible distribution / compatibility.
>>>Yes, but it also limits you to C as it stood 20 years ago. And counting. Is there no point at which a more recent standard should be adopted? Among features of C11 I use:
This is the trade-off. As with many of us I've been living this for decades. This is the genesis of the 'breaking change', which is a killer for those of us supporting older software.
>>>SQLite would benefit from all of those, plus UTF-8 string constants.
>>>I full well understand the workarounds for integer sizes and Booleans are baked into SQLite, and there's no real need to adopt the new (er,
>>>new-ish) forms. VLAs and designated initializers should not be underestimated, though. There are many places in SQLite where VLAs could replace local malloc/free pairs, and SQLite code is rife with structures that can be more succintly initialized with the modern syntax.
UTF-8 perhaps but I don't think VLA's are to be considered. Without going into the history, VLA's are (a) not part of C++ (b) not guaranteed to be supported by all compliant C compilers (c) optional in C11 (see _ _STDC_NO_VLA_ _) (d) not guaranteed to be required by future C standards. They're a lovely feature if you know exactly which compiler(s) you're working with.
>>>Nowawdays, once again making a living writing C code and having the daily opportunity to experiment the the new language features, I've come to like them. C is a sharp-edged language, and has become a bit fussy as the compilers writers have adopted, as we've discussed here, pedantic notions of UB. OTOH, it's an improvement to relieve the language of some of its ancient constraints, such as static array sizes and the prohibition on type-punning in unions (which began as SOP, then was UB, and is now OK again).
I would never use C if C++ is available. If I have to, I choose a conservative feature set. There may be good reasons for Sqlite to move to C99 (the main one being that it's already a 15yo standard), but it's not a decision to be taken lightly or piecemeal. C11 has barely taken off its training wheels.