Simplify structure declaration, why not?

Started by koluibuoc, June 05, 2009, 01:53:54 AM

Previous topic - Next topic

koluibuoc

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!

AlexN

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. ;)
best regards
Alex ;)

Romashka

The following code works with /Ze option:
typedef struct node node;

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

JohnF

Or like this.


typedef struct node NODE;

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

int main(void)
{
NODE node;



John