user1899020
user1899020

Reputation: 13575

how to check if a type is defined or not?

For example

typedef float Real;

And want to check if Real is defined or not? For macro, it is easy

#define Real float
#ifndef Real
#define Real float
#endif

How about typedef?

Upvotes: 2

Views: 1401

Answers (1)

Cheers and hth. - Alf
Cheers and hth. - Alf

Reputation: 145249

Any typedef can be repeated (with the same definition), so you don't need to check if it already exists.

Caveat: old versions of g++ didn't quite following the standard's rules. The solution then, for the particular problem at hand then, was to generate probably unique identifiers.

Upvotes: 2

Related Questions