Proposed platform assumption changes

Nico Williams nico at
Sun Jan 29 15:17:14 EST 2012

On Fri, Jan 27, 2012 at 5:55 PM,  <ghudson at> wrote:
> * Named structure initializers appear to be a favorite C99 feature;
>  we've had three separate cases in the past year of people submitting
>  code using them and having to ask for it to be changed.
>  Unfortunately, it's not supported in MSVC, and there's no pretty way
>  of wrapping them to make it work there.  We could consider changing
>  our Windows build to use mingw, but that would be a lot of work and
>  might present other issues.

I just tried the following macro for dealing with this.  It works, and
in particular cscope finds the initializers when I search by struct
field name -- a critical feature of C99 designated initializers, IMO.
I posted it as an answer on stackoverflow too (I was looking for this,
didn't find it).  This does require building with a C99 compiler for
checking correctness, but MIT krb5 already does that anyways, but a
variant that includes the struct name as a macro argument would allow
for a script to check correctness if that were important.

 * Macro for C99 designated initializer -> C89/90 non-designated initializer
 * Tested.  Works with MSVC if you undefine
 * groks this.
 * ("SFINIT" == struct field init, but really, it can be used for
array initializers too.)

#define SFINIT(f, v) f = v
#define SFINIT(f, v) v

struct t {
    char f1;
    int f2;
    double f3;

struct t t = {
    SFINIT(.f1, 'a'),
    SFINIT(.f2, 42),
    SFINIT(.f3, 8.13)



More information about the krbdev mailing list