cc-rs icon indicating copy to clipboard operation
cc-rs copied to clipboard

cc interprets quotes in CFLAGS/CXXFLAGS differently from CMake

Open heinrich5991 opened this issue 3 years ago • 1 comments

For CMake, CXXFLAGS="'-DRETURN1=return 1;'" generates a macro that returns 1, in cc, this is interpreted as an argument '-DRETURN1=return and an argument 1;'. This seems undesirable.

Would a patch fixing this be accepted?

heinrich5991 avatar Sep 08 '22 08:09 heinrich5991

For CMake, CXXFLAGS="'-DRETURN1=return 1;'" generates a macro that returns 1

Have you verified that CMake also behaves like this on Windows? AFAIK (but I may be wrong) on windows shells this doesn't work because single quotes don't have the same meaning as on Linux/macOS. An Alternative solution would be that cc reads an environment variable like ENCODED_CXXFLAGS, which would be split by Ox1f same as CARGO_ENCODED_RUSTFLAGS.

jschwe avatar Feb 08 '23 19:02 jschwe