Rechercher

PythonReactSEOPDF
GitHub Skill

patternscallback-context

Callback + Context Pattern (C-Specific) pattern for C development

mgreenly☆ 1 Étoiles du dépôt0 Forks du dépôt

Installation

Suivez les instructions du dépôt pour votre agent. Consultez les fichiers et dépendances avant l’installation.

Voir la source ↗Guides

Instructions

Callback + Context Pattern (C-Specific)

Pair function pointer with void * user data. Callback receives user data, enabling state access without globals. Universal C pattern for async/event handling.

ikigai Application

Streaming responses:

typedef void (*chunk_cb_t)(void *user_ctx, const char *data, size_t len);

res_t ik_llm_stream(ik_llm_client_t *client,
                    ik_message_t **msgs,
                    chunk_cb_t on_chunk,
                    void *user_ctx);  // Passed to callback

Usage: REPL passes itself as context, callback updates scrollback.

Convention: Callback function pointer immediately followed by void * context parameter. Callback signature includes context as first param.

Benefit: Stateful callbacks without globals. Each caller provides own context.

Exemples

Consultez les exemples du dépôt source.

Voir la source ↗

Historique source

Date d’indexation
2026-01-20
Mise à jour de l’index
2026-01-26
Branch
main

Les dates concernent ce répertoire. Consultez le dépôt pour l’historique du code.

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!