Skip to content

Weird behavior with #def and -preprocess-def-macro #445

Description

@Psteven5

First off, I really like this project! I have given a whirl at an extended C myself but this is probably the best variant I've seen about.

So I don't know if this is intended behavior, but this code snippet:

#define CAT2_(A,...) A##__VA_ARGS__
#define CAT2(...) CAT2_(__VA_ARGS__)

#define STRINGIFY_(...) #__VA_ARGS__
#define STRINGIFY(...) STRINGIFY_(__VA_ARGS__)

#def IMPORT(Module)
    #ifndef CAT2(Module,_h)
    #define CAT2(Module,_h)
    #include STRINGIFY(CAT2(Module,.h))
    #endif
#enddef

IMPORT(stdio)
IMPORT(stdio)

int main(void)
{
}

leads to very cryptic errors:

Cake 0.14.00 (x86_x64_gcc)
main.c:8:28:
error 970: expected token 'identifier', got 'new line'

 8 |
   |~

main.c:9:28:
error 970: expected token 'identifier', got 'new line'

 9 |
   |~

While having only one IMPORT(stdio) compiles and includes <stdio.h> as one would expect.

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