Re: Question regarding bizarre ','

Daniel Jacobowitz
2002-08-06T01:26:49Z

On Mon, Aug 05, 2002 at 06:21:35PM -0700, Joel Brobecker wrote:
> This is where I show my lack of C-knowledge:
>
> in i386v4-nat.c, I read the following code:
>
> /* Mapping between the general-purpose registers in `/proc'
> format and GDB's register array layout. */
> static int regmap[] =
> {
> EAX, ECX, EDX, EBX,
> UESP, EBP, ESI, EDI,
> EIP, EFL, CS, SS,
> DS, ES, FS, GS,
> };
>
> I would have thought that the last ',' would cause a compilation error.
> But this seems to compile fine. Any reason for keeping this last comma?

It makes it easier to add an element without having to touch any
existing line, to make diffs clearer. A trailing comma in an array
initializer (or struct initializer maybe?) is ignored.

--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer