by bluetomcat · 5y ago · 0 comments
I tend to disagree. Unless you are providing an API for third-party use and want to make your data types opaque to callers, do not ever use typedef with structs and pointers. A declaration like "struct foo *f" tells you two things - f itself is a pointer, and the pointed-to value is not a scalar (i.e. has named members). The "_t" suffix idiom is predominantly used by the standard library for integral scalars with certain properties and semantics, e.g. pid_t, uid_t, gid_t, time_t.
typedef struct VkMemoryBarrier {
VkStructureType sType;
const void* pNext;
VkAccessFlags srcAccessMask;
VkAccessFlags dstAccessMask;
} VkMemoryBarrier;I agree with just using struct foo, as does the Linux style guide.
(Edit: I just noticed the page mentions this, but it is perhaps useful to reiterate.)
https://www.gnu.org/software/libc/manual/html_node/Reserved-...
That said, typedefs/macros may be essential for portability concerns.
The solution to that problem is don't do that.