Skip to content

#include directive if the macro is undefined #158

@s311354

Description

@s311354

Hello,

It seems that chibicc currently does not process #include directives properly if the macro is undefined.

The C standard says, to quote ISO/IEC 9899:1999:

A preprocessing directive of the form # include pp-tokens new-line (that does not match one of the two previous forms) is permitted. The preprocessing tokens after include in the directive are processed just as in normal text. (Each identifier currently defined as a macro name is replaced by its replacement list of preprocessing tokens.) The directive resulting after all replacements shall match one of the two previous forms. The method by which a sequence of preprocessing tokens between a < and a > preprocessing token pair or a pair of " characters is combined into a single header name preprocessing token is implementation-defined.

For example the following:

#include UNDEFINED

expected error message by the standard (which gcc and clang conforms to) is:

error: #include expects "FILENAME" or <FILENAME>
 #include UNDEFINED

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