Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Implementing `flag_count` and `flag_get`

Open
#16 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
c
Domain
cli

Research direction

Start with the TODO in example.c and inspect the existing flag API and Flag_Context usage before assessing the proposed flag_count and flag_get functions. Done requires resolving the public Flag_Info shape, value representation, and compatibility implications, which the issue leaves open.

Written by the indexing model from the issue text.

Description

You have the following comment in example.c:

 // TODO: Would be nice to have some sort of mechanism to inspect all the defined flags
 //   Maybe just expose flag_global_context? But I'm afraid that this will make changing
 //   its internal structure in a backward compatible way more difficult...
 //   But the only reason we may want to change it right now is to make the array of the
 //   flags dynamic. Maybe we should just make it dynamic and finally expose the internal
 //   structure for good?

What about implementing functions flag_count and flag_get(i) as a compromise?

I mean, the API could look like:

size_t flag_count(void);
const Flag_Info *flag_get(size_t index);

where Flag_Info is a structure, something like:

typedef struct {
    const char *name;
    Flag_Type   type;
    const char *desc;
    const void *value;  // or provide a separate function to read the current value 
} Flag_Info;

In this case, the Flag_Context stays private, but we can iterate for (size_t i = 0; i < flag_count(); ++i) and collect metadata if needed.
We may also add more fields to Flag_Info, for example, a default value or a field that indicates whether “was this flag provided?”, or something else.

Should I try to implement this?

Dominant language
C
Stars
295
Forks
20
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tsoding/flag.h

All issues in tsoding/flag.h

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.