Skip to content

Look into __VA_OPT__ for C23 #45

@duarm

Description

@duarm

Feature Request

What is the nature of this request?

  • Change in source code details (names of variables, functions, parameters, etc)

Is your feature request related to a problem? Please describe.

cmc log functions from log.h, cmc_log_trace for example, are defined as:

#define cmc_log_trace(fmt, ...) cmc_log(CMC_LOG_TRACE, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)

##__VA_ARGS__ is supported by most compilers, but still non-standard, -pedantic issues a warning about it.

C23 solves the problem by introducing the __VA_OPT__ preprocessor. So this is the C23 solution:

#define cmc_log_trace(fmt, ...) cmc_log(CMC_LOG_TRACE, __FILE__, __func__, __LINE__, fmt __VA_OPT__(,)  __VA_ARGS__)

Full C23 support is yet to be available, so not a high priority.

Describe the solution you'd like

Detect the version via __STDC_VERSION__, and use the standard solution if C23 or later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions