zig icon indicating copy to clipboard operation
zig copied to clipboard

`zig cc` can't accept -- in args

Open iacore opened this issue 2 years ago • 7 comments

Zig Version

0.11.0-dev.1898+36d47dd19

Steps to Reproduce and Observed Behavior

> zig cc -- program.c
error: Unknown Clang option: '--'

Expected Behavior

It should parse like clang. args after -- are not flags.

iacore avatar Mar 08 '23 01:03 iacore

Are you sure that's actually how clang works? I ran clang -- -program.c where -program.c exists and it said:

error: unknown argument: '-program.c'

ghost avatar Mar 08 '23 06:03 ghost

-program.c should be a file name, if your C file starts with -.

iacore avatar Mar 08 '23 06:03 iacore

Yes, clang for me shows that error message when -program.c is the name of a C source file. My clang version is 15.0.7, what version are you on?

ghost avatar Mar 08 '23 08:03 ghost

Yes, clang for me shows that error message when -program.c is the name of a C source file. My clang version is 15.0.7, what version are you on?

I gave a bad example. What about clang -- program.c

iacore avatar Mar 08 '23 18:03 iacore

Strange, I've found that actually clang for me does process the -- as expected, even with -program.c... but only if -program.c doesn't exist.

clang -- -program.c where -program.c doesn't exist:

clang-15: error: no such file or directory: '-program.c'
clang-15: error: no input files

clang -- -program.c where it does exist:

error: unknown argument: '-program.c'

ghost avatar Mar 09 '23 05:03 ghost

Did we find a bug in clang?

iacore avatar Mar 09 '23 22:03 iacore

I dunno, seems like it :shrug:

ghost avatar Mar 10 '23 04:03 ghost

This is not demonstrated to be a bug yet. Please improve the bug report

andrewrk avatar Apr 10 '23 16:04 andrewrk

This is not demonstrated to be a bug yet. Please improve the bug report

Updated

iacore avatar Apr 11 '23 09:04 iacore