[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnucap-devel] C question
From: |
Galen Seitz |
Subject: |
Re: [Gnucap-devel] C question |
Date: |
Mon, 19 Feb 2007 08:36:42 -0800 |
User-agent: |
Thunderbird 1.5.0.9 (X11/20061222) |
al davis wrote:
I ran into this in ngspice code ...
A structure ....
typedef struct SPICEdev {
int (*DEVparam)(int,IFvalue*,GENinstance*,IFvalue *);
int (*DEVmodParam)(int,IFvalue*,GENmodel*);
int (*DEVload)(GENmodel*,CKTcircuit*);
int (*DEVsetup)(SMPmatrix*,GENmodel*,CKTcircuit*,int*);
} SPICEdev;
is initialized like this ....
SPICEdev CCCSinfo = {
DEVparam : CCCSparam,
DEVmodParam : NULL,
DEVload : CCCSload,
DEVsetup : CCCSsetup
};
I would expect this (as it is in Spice 3f5) ....
SPICEdev CCCSinfo = {
CCCSparam,
NULL,
CCCSload,
CCCSsetup
};
The way it is done in ngspice is certainly an improvement, but I
could not find any documentation for that syntax. It obviously
works, at least with gcc. Is this a gcc extension? Can
someone point me to some official documentation?
I am not looking for an explanation of how this feature works
and why to use it. It is obvious to me. I am looking for a
reference to official documentation. It is a good feature, that
I would like to use, but I will only use it if it is part of
the official language.
Using a colon in an initializer is an obsolete GCC syntax. C99
now allows for designated initializers. See
http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
In a structure initializer, specify the name of a field to initialize with
`.fieldname =' before the element value. For example, given the following
structure,
struct point { int x, y; };
the following initialization
struct point p = { .y = yvalue, .x = xvalue };
is equivalent to
struct point p = { xvalue, yvalue };
Another syntax which has the same meaning, obsolete since GCC 2.5, is
`fieldname:', as shown here:
struct point p = { y: yvalue, x: xvalue };
galen