Skip to content

zig cc -E -c X differs from clang/cpp preprocessor modes #23269

Open
@kkartaltepe

Description

@kkartaltepe

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

Create a test file:

%{
CUT_OUT_BEGIN
#include <fontconfig/fontconfig.h>
CUT_OUT_END
%}

Run: zig cc -E -P -c test.h

observe:

test.h:1:1: error: expected identifier or '('
    1 | %{
      | ^
1 error generated.

Expected Behavior

It should execute without error, examples that succeed clang -E -P -c test.h, cpp -E -P -c test.h, gcc -E -P -c test.h

It seems related to using the -c flag, since zig cc works when using zig cc -E -P test.h

This is how meson's cc.preprocess command generates calls and is used in the fontconfig project so resolving this would allow compiling fontconfig with zig cc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorzig ccZig as a drop-in C compiler feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions