Currently we can define structs and unions, but no variables of these types. The following example should work:

struct s {
  int f;
};

struct s svar;
Submitted by Guido Wachsmuth on 4 April 2013 at 18:24

On 24 April 2013 at 21:02 Daco Harkes commented:

This is can currently be done in a c manner

s svar; //without the struct

On 24 April 2013 at 21:30 Guido Wachsmuth commented:

@Daco: Is the latter correct C? I don’t think so. There are (at least) three different ways:

First my example:

struct s {
  int f;
};

struct s svar; 

Second, with a type definition:

typedef struct s {
  int f;
} stype ;

stype svar; 

Third, anonymously:

struct {
   int f;
} svar;

Please check the language documentation to confirm.


On 24 April 2013 at 21:36 Daco Harkes tagged basec

On 2 May 2013 at 14:24 Daco Harkes tagged @dario

On 7 May 2013 at 12:55 Dario Nesi commented:

now the syntax support this kind of declarations:

standard definition and declaration

struct X{
    int32 y;
};
struct X z;

definition with declaration togheter

struct X{
    int32 y;
} z;

anonymous definition and variable declaration

struct {
    in32 y;
} z;

On 8 May 2013 at 15:23 Mircea Voda closed this issue.

On 8 May 2013 at 15:27 Dario Nesi reopened this issue.

On 8 May 2013 at 15:27 Dario Nesi closed this issue.

Log in to post comments