[ C Frontend / Preprocessor ] Embed Preprocessor Parameter Order

David Brown david.brown@hesbynett.no
Tue Jun 10 07:52:42 GMT 2025


On 09/06/2025 12:13, Andreas Schwab wrote:
> On Jun 09 2025, Chris Bazley via Gcc wrote:
> 
>> C is a language that allows considerable latitude in where things are placed:
>>
>>      static int volatile p;
>>      volatile int static q;
> 
> C23 says (6.11.5 Storage-class specifiers):
> 
>      The placement of a storage-class specifier other than at the
>      beginning of the declaration specifiers in a declaration is an
>      obsolescent feature.
> 

C90 has the same paragraph under "Future language directions".  Killing 
off obsolescent features in C takes a /long/ time.  C23 did manage to 
drop non-prototype function declarations and K&R-style function 
definitions, which also were market obsolescent in C90.


The latitude that C allows for ordering in declarations comes from two 
main sources.  Sometimes it is because it was thought that it made the 
syntax and grammar rules of the language simpler.  But mostly it was 
because the original C standard was formed from existing practice - 
existing inconsistent C compilers, and existing inconsistent C source 
code.  It allowed "static int volatile" and "volatile int static" 
because enforcing an order - /any/ order - would make significant 
existing C code incorrect with the new standard.  It was not done for 
good language design - it was done despite it being a bad feature for 
the language.


So while correcting the mistakes of the past is either very slow or 
impossible, we can avoid them in the future.  Consistent parameter order 
makes code clearer and neater, and should be encouraged.

David




More information about the Gcc mailing list