[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] anonymous structs and C99



Hello.

That kind of syntax is a Microsoft extension ;-)
You can use it along with -std=c99 if you add -fms-extensions
Well, if you want to be standard compliant, it is not a good idea.

You should have noticed the warning :
a.c:52: warning: declaration does not declare anything

In C99, your union is only a new type, but it is unused since you didn't declare a variable.

The solution is:

struct xxx
{
  int x;
  int y;
  union
  {
    char* pointer1;
    int* pointer2;
  } u; // HERE
} a;

Then you can use a.u.pointer1
Of course, no cast is required !

--
Vincent Rivière