On Wed, Feb 04, 2015 at 03:33:50PM -0500, D. Hugh Redelmeier wrote: > When the code was originally written, there was no c99. I guess we > are long past those days and we should start taking advantage of the > new features. > > I think declaring the variable in the for-head is one of the nicer > little features. It goes along with my desire to keep variables as > local as possible. > > There has been a strong temptation to use the same index variable in > sibling for statements: it cuts down in the number of declarations and > lines. I think this new form eliminates that excuse. > > Why does gcc require a flag? Is using c99 so remarkable that it cannot be > the default? Is there any downside? At least some things we already use > were introduced in C99.
Well making it the default could make older code no longer compile. That's pretty bad (and would be rather like what modern C++ compilers do to older perfectly valid C++ code). So I think gcc's behaviour for C99 is much better than g++'s treatment of older C++ code. > What other C99 features are worth using? > > - local declarations mixed in with statements. We've avoided this > (mostly) but it is sometimes quite nice. Actually, this predates C99. > This allows us to have fewer variables that are uninitialized. Certainly something that can have lots of arguments over weather that is a great idea or terrible code style. > - I think that we already use the struct and union member initializing > syntax > > - Variable Length Arrays (VLAs) have been made optional-to-support in the > more recent standards so we should not use them. Too bad: they could > do what alloca was used for. I can't remember what the problem they caused was and why they were made optional. Must have been some reason. > - inline functions -- we already use them. How come we don't need > -std=c99 already? Just because they are now part of the standard and hence required to be supported by a standards compliant compiler does not mean compilers were not allowed to permit them before hand. > - <stdbool.h>: we should replace the bool abstraction that I created. > Should be trivial > > - <inttypes.h> I think we already use it Those two are certainly nice things to be able to rely on. > - // we use this a bit. I don't like it except in special cases. > > - compound literals: might be useful OK I am going to have to go look up what that is. Hmm, having looked them up I am still not sure what is supposed to be new and exiting about them. -- Len Sorensen _______________________________________________ Swan-dev mailing list Swan-dev@lists.libreswan.org https://lists.libreswan.org/mailman/listinfo/swan-dev