0

C-Interface is created for C++ API. some variable are defined for C++'s API object like :

typedef struct object* object;

other approach is used

typedef void* object;

My lead suggested that typedef struct object* object this is good . But I don't understand why this is better design. Which is good design and why ?

Thanks in advance

Undefined Behaviour
  • 729
  • 2
  • 8
  • 27
  • 1
    It's not a good idea to throw away type information. Or for that matter any useful information. – Cheers and hth. - Alf Sep 10 '16 at 08:27
  • 1
    For black-box structures (like `FILE` in C) go with the first alternative. But I recommend you do like `FILE` and don't define the type-alias as a pointer. – Some programmer dude Sep 10 '16 at 08:30
  • @Nawaz I think my question is different from question you marked as duplicate. In that question class is declared already. But here i am only making object to struct object*. sorry if i am wrong. – Undefined Behaviour Sep 10 '16 at 08:37
  • @vidhugangwar: Here you are discussing two approaches, both of them are discussed in the other thread. Apart from them, the other thread also mentions a third approach. – Nawaz Sep 10 '16 at 08:40

0 Answers0