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

Lennart Sorensen lsorense at csclub.uwaterloo.ca
Thu Feb 5 16:47:27 EET 2015


On Thu, Feb 05, 2015 at 01:13:49AM -0500, D. Hugh Redelmeier wrote:
> Really?  Seems like a no-brainer if you accept the goal of minimizing
> undefined variable errors.

I agree, but I have heard people argue that all variables should be
declared first.  Probably just old fashioned C coders.

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

They sure don't bother implementing modern C++ fully either.

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

Perhaps because some people thought they were evil and shouldn't be
allowed unless you explicitly say you want the new standard.  Who knows
why the gcc developers do anything.

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

Oh is that what they were trying to show as new.  That sure wasn't clear
in the gcc documentation on it.

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

I love when the compiler spots errors at compile time.

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

Nifty.

-- 
Len Sorensen


More information about the Swan-dev mailing list