Karan Kalra
Karan Kalra

Reputation: 413

Typedef struct use in c

struct pointsto_val_def
{
    unsigned int lhs;
    bitmap rhs;
    struct pointsto_val_def *next;
};
typedef struct pointsto_val_def *pointsto_val;

typedef pointsto_val *pointsto_val_hash;

Can the last two statements be simply replaced by this one statement?

typedef struct pointsto_val_def *pointsto_val_hash

Thanks in advance. Cheers.

Upvotes: 0

Views: 196

Answers (2)

MYMNeo
MYMNeo

Reputation: 836

I think the answer is no.Because the type of pointsto_val_hash is struct pointsto_val_def**, that means pointsto_val_hash is a pointer which is pointed to struct pointsto_val_def*.And your replacement means a pointer which is pointed to struct pointsto_val_def, they are not the same.

Upvotes: 1

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84151

You can replace it with one typedef if you don't need the _val type, but with a double-pointer:

typedef struct pointsto_val_def** pointsto_val_hash;

Upvotes: 0

Related Questions