Skip to content

"Restrict" qualifier not reconised in C headers. #991

@thepigeongenerator

Description

@thepigeongenerator

OS: Linux
EDITOR: neovim
CC: gcc
VERSION 0.20250815.1

It appears that C++ is assumed over C, in *.h header files.
Personally, I am under the opinion C++ should leave C++-specific code in *.hh or *.hpp or whatever other combination of file extensions were standard. But, this isn't the case and I cannot do anything about that.

I am unaware how the code is structured, and I might take a peek at a later date. However, some potential solutions I have in mind are:

  • "pretending" a macro is defined for restrict pointing to __restrict__, this might signal to the user that some funky stuff may be happening to restrict.
  • Otherwise, mark restrict as a valid keyword in *.h files, and let the compiler solve the confusion on the user's end.

Interestingly, when I defined a macro in my codebase like this:

#if defined(__cplusplus)
#define restrict __restrict__
#endif

It is assumed that the restrict qualifier is using the macro.

Image with some code in a header file, showing the error 'expected )'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions