[Swan-dev] Add -std=c99 to the compiler flags?

D. Hugh Redelmeier hugh at mimosa.com
Thu Feb 5 08:13:49 EET 2015


| From: Lennart Sorensen <lsorense at csclub.uwaterloo.ca>

| > - 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.

Really?  Seems like a no-brainer if you accept the goal of minimizing
undefined variable errors.

| > - 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.

I seem to remember that it was added to C but C++ didn't take it up so
the C folks backed down on mandating it (in the next standard).

Mind you Microsoft doesn't bother to implement modern C.  Perhaps that
was a factor, I don't know.

| > - 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.

Right.  But that also applies to declarations in for statement's expr1.  
So why didn't they throw that in for free too?

| > - 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.

You could create struct variables and initialize them, but that isn't
possible in the middle of an expression or a function-like macro.

Kind of like the way you can define functions, but in some situations
lamdas are nice.

For example, I introduced struct wrappers for time because we were
confusing different kinds of time.  This turns those mistakes into
type errors that the compiler will diagnose.

There is currently pushback because function-like macros cannot have
time constants as values.  This feature could fix that.  But that may
not be the best way.


More information about the Swan-dev mailing list