Skip to content

Syntax error with #if and designated initializer #297

@chrchr-github

Description

@chrchr-github

From the forum: https://sourceforge.net/p/cppcheck/discussion/general/thread/2cc604d687

struct S { int i; };
struct S s = {
#if 1
            .i = 1,
#endif
};
bar.cpp:3:0: error: Syntax error in #if [preprocessorErrorDirective]
#if 1
^

The tokens 1 and . are combined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions