Pelles C forum

Pelles C => Feature requests => Topic started by: koluibuoc on June 05, 2009, 01:53:54 AM

Title: Simplify structure declaration, why not?
Post by: koluibuoc on June 05, 2009, 01:53:54 AM
Hello Pelles

First, I want to send my thanks to you, Pelles. I really like PellesC!
You have done the great work.

Second, I hope some days in the future PellesC will accept this:

struct Node
{
   int data;
   Node *left;
   Node *right;
}

void main()
{
   Node node;
   ....
}

Because i find structure declaration so confusing and not easy to remember. And I'm lazy to type much. :)

That all.

Hope final PellesC 6.0 will be out soon.

Have a nice day!
Title: Re: Simplify structure declaration, why not?
Post by: AlexN on June 05, 2009, 07:02:33 AM
Quote from: koluibuoc on June 05, 2009, 01:53:54 AM
struct Node
{
   int data;
   Node *left;
   Node *right;
}

void main()
{
   Node node;
   ....
}

Because i find structure declaration so confusing and not easy to remember. And I'm lazy to type much. :)
Pelles C can not translate your code exactly, but this can be translated:

#include <stdio.h>

#define Node struct _NODE

Node
{
   int data;
   Node *left;
   Node *right;
};

int main()
{
   Node node;
   node.left = NULL;
   node.right = NULL;
   node.data = 0;

   return node.data;
}

I am sure that this is a good solution, but it is near of that what you want. ;)
Title: Re: Simplify structure declaration, why not?
Post by: Romashka on June 05, 2009, 05:26:41 PM
The following code works with /Ze option:
typedef struct node node;

typedef struct node {
   node *prev;
   node *next;
   void *value;
} node;
Title: Re: Simplify structure declaration, why not?
Post by: JohnF on June 05, 2009, 08:45:48 PM
Or like this.


typedef struct node NODE;

struct node{
    NODE *prev;
    NODE *next;
    void *value;
};

int main(void)
{
NODE node;



John