aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMotiejus Jakštys <motiejus@jakstys.lt>2022-11-14 04:15:04 +0200
committerAndrew Kelley <andrew@ziglang.org>2023-01-13 21:38:11 -0500
commit6b3f59c3a735ddbda3b3a62a0dfb5d55fa045f57 (patch)
tree457c3ef57718e31cd6297bb3154dcb6177793027 /tools
parentd813cef42af43b499fc5dc465e34f873008aaad0 (diff)
downloadzig-6b3f59c3a735ddbda3b3a62a0dfb5d55fa045f57.tar.gz
zig-6b3f59c3a735ddbda3b3a62a0dfb5d55fa045f57.zip
zig run/cc: recognize "-x language"
This commit adds support for "-x language" for a couple of hand-picked supported languages. There is no reason the list of supported languages to not grow (e.g. add "c-header"), but I'd like to keep it small at the start. Alternative 1 ------------- I first tried to add a new type "Language", and then add that to the `CSourceFile`. But oh boy what a change it turns out to be. So I am keeping myself tied to FileExt and see what you folks think. Alternative 2 ------------- I tried adding `Language: ?[]const u8` to `CSourceFile`. However, the language/ext, whatever we want to call it, still needs to be interpreted in the main loop: one kind of handling for source files, other kind of handling for everything else. Test case --------- *standalone.c* #include <iostream> int main() { std::cout << "elho\n"; } Compile and run: $ ./zig run -x c++ -lc++ standalone.c elho $ ./zig c++ -x c++ standalone.c -o standalone && ./standalone elho Fixes #10915
Diffstat (limited to 'tools')
-rw-r--r--tools/update_clang_options.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig
index 889e5bcbfe..85558576df 100644
--- a/tools/update_clang_options.zig
+++ b/tools/update_clang_options.zig
@@ -500,6 +500,10 @@ const known_options = [_]KnownOpt{
.name = "undefined",
.ident = "undefined",
},
+ .{
+ .name = "x",
+ .ident = "x",
+ },
};
const blacklisted_options = [_][]const u8{};