mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
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
|
||
|---|---|---|
| .. | ||
| spirv | ||
| extract-grammar.zig | ||
| gen_outline_atomics.zig | ||
| gen_spirv_spec.zig | ||
| gen_stubs.zig | ||
| generate_linux_syscalls.zig | ||
| process_headers.zig | ||
| stage1_gdb_pretty_printers.py | ||
| stage2_gdb_pretty_printers.py | ||
| stage2_lldb_pretty_printers.py | ||
| stage2_pretty_printers_common.py | ||
| std_gdb_pretty_printers.py | ||
| update-license-headers.zig | ||
| update-linux-headers.zig | ||
| update_clang_options.zig | ||
| update_cpu_features.zig | ||
| update_glibc.zig | ||
| update_spirv_features.zig | ||
| zig_gdb_pretty_printers.py | ||