patternsopaque-pointer
Opaque Pointer Pattern pattern for C development
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
Opaque Pointer Pattern
Declare struct in header without defining fields. Implementation hidden in .c file. Callers only see pointer, never fields.
ikigai Application
Header:
typedef struct ik_scrollback ik_scrollback_t; // Forward declaration
res_t ik_scrollback_create(void *ctx, ik_scrollback_t **out);
Implementation in .c:
struct ik_scrollback {
// Fields hidden from callers
};
Benefits:
- Callers can't depend on internal fields
- Change internals without recompiling callers
- Enforces use of accessor functions
ikigai usage: Most context types could use this. Currently structs are defined in headers. Consider for stable public APIs.
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-01-20
- Index updated
- 2026-01-26
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!