D
dr.oktopus
Hello,
a proper way to implement an opaque type in c language is hide
its implementation in .c files, and typedef a pointer to it in .h like
this:
typedef struct list_st *list;
list new_list (void);
...
However, I note that often this way is a little modified to
keep out the pointer from the declaration of the new type
(example from a stdio.h):
typedef struct __iobuf *FILE;
Perhaps since C programmers want explicit pointers.
An opaque struct typedef'ed without a pointer could
cost in terms of efficiency when passing/receiving
to/from functions, so why risk?
Tell me what you think
a proper way to implement an opaque type in c language is hide
its implementation in .c files, and typedef a pointer to it in .h like
this:
typedef struct list_st *list;
list new_list (void);
...
However, I note that often this way is a little modified to
keep out the pointer from the declaration of the new type
(example from a stdio.h):
typedef struct __iobuf *FILE;
Perhaps since C programmers want explicit pointers.
An opaque struct typedef'ed without a pointer could
cost in terms of efficiency when passing/receiving
to/from functions, so why risk?
Tell me what you think