Skip to content

[config.h] Consider changing how defines are used in raylib to support configuration from build systems #4411

Open
@planetis-m

Description

@planetis-m

Description:
Currently, raylib uses #if defined(SUPPORT_X) to conditionally enable/disable certain features like file format support. However, setting a define to 0 from the build system (e.g., -DSUPPORT_FILEFORMAT_PNG=0) doesn't actually disable the feature because the macro is still considered "defined."

This limitation makes it difficult to selectively disable certain features without manually editing config.h, especially when working with different build systems or when trying to configure raylib via command-line flags alone.

Proposed Change:
Switch the current #if defined(SUPPORT_X) checks to something like #if SUPPORT_X == 1. This would allow features to be properly toggled off by defining them as 0 from the build system.

Example:

#ifndef SUPPORT_FILEFORMAT_PNG
#define SUPPORT_FILEFORMAT_PNG 1
#endif

#if SUPPORT_FILEFORMAT_PNG
    // PNG support code
#endif

This would enable features to be turned off using -DSUPPORT_FILEFORMAT_PNG=0 in the build system, without requiring edits to the default configuration file.

Discussion Summary:
This topic was discussed on the raylib Discord server. The current method was found to be limiting for build systems that rely on command-line defines. While the change is agreed to be useful, it was also acknowledged that it's better suited for a future release after the current planned version has been completed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThis is an improvement of some feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions