[Geany-Devel] Lets move to C99

Nick Treleaven nick.treleaven at xxxxx
Fri Aug 16 11:38:23 UTC 2013


On 16/08/2013 07:36, Lex Trotman wrote:
> The more we can allow modern(ish :) programming styles using a well known
> standard the simpler it is to produce correct code (eg inlines not macros,
> who will remember that EMPTY may compute its arguments multiple times).

That's why it's in capitals, so it's clear it's a macro. An inline would 
be better, good idea. Though for FALLBACK we don't know the return type.

> At the moment C11 is too new (not enough complete support) but C99 is fine.
>
> Unless we follow the example of gcc itself and upgrade to C++ :)

Not sure that's a good idea for Geany now, although I'm glad that gcc 
did it. They use a restricted subset IIRC. I miss templates and RAII in 
C though.

>> ** - restricted pointers

C90 allows __restrict.

>> ** - variable-length arrays

Not sure that's much better than g_alloca.

>> ** - flexible array members

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0472c/BABECHJI.html

Looks interesting, not sure we'll use it though.
There's some other C99 info on that site in the sidebar.

>> ** - // comments

yes please

>> ** - mixed declarations and code

nice

>> ** - inline functions

C90 allows __inline (GLib also has a macro for it).

>> ** - the snprintf family of functions

g_snprintf?

>> - Allowed to use // style comments
>> - Allowed to declare loop counter-style variable inside the for loop.

amen

>> - Use standard C instead of G*-portability wrappers in various place
>> (bool, fixed-width ints, etc.).

I might use bool because it's shorter than gboolean, but I'm not sure 
about the others.

</tuppenceworth>


More information about the Devel mailing list