Skip to content

[Feature]: Support configurable C macros and function declarations #5601

Backlog

Description

@rudolfmleziva

Problem or use case

Graphify 0.9.53 parses C files without expanding project macros and does not index function prototypes. This affects projects that use declaration macros.

For example, with this synthetic header:

Graphify reports a parse error and emits only the file node. Replacing EXTERN with extern removes the parse error, but the prototype still does not appear in the graph.

Requested behavior:

Allow configurable C macro definitions or preprocessing options, including function-like macros.
Extract function declarations as well as definitions, with correct names and source locations.
Preserve existing behavior when the feature is not configured.
Add tests for macro-wrapped declarations and definitions, including declarations linked to their definitions.
I intend to work on a patch for this feature.

Proposed solution

Add opt-in C preprocessing configuration, similar to Doxygen: macro definitions, include paths and target-specific defines.
Parse the preprocessed result, mapping extracted symbols back to their original file and line.
Extract function declarations as well as definitions, linking matching prototypes and definitions without collapsing unrelated functions.
Preserve current behavior when preprocessing is not configured.
For example, configuration could define EXTERN=extern and describe function-like macros such as FUNC(type, section)=type.

The main design question is whether to use an external C preprocessor or implement limited macro normalization. I’d favor an external preprocessor for correct macro expansion and conditional compilation, provided original source locations can be preserved.

Alternatives considered

No response

Area

Extraction or language support

Are you willing to submit a PR?

Yes, I can work on this

Compatibility / behavior impact

The feature should be opt-in. Existing C extraction behavior should remain unchanged when no preprocessing configuration is provided.

When enabled, the graph may contain additional function declarations and corrected symbols. Results depend on the configured macros, include paths and build variant. Extracted symbols should retain their original source locations.

If an external preprocessor is used, it becomes a dependency only for users who enable this feature. Preprocessing failures should be reported explicitly.

Additional context

No response

Activity

  1. added
    enhancement
    on Nov 28, 2026
  2. github-actions commented on Nov 28, 2026

    @github-actions

    Thanks for opening this issue, @rudolfmleziva. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions