mirror of
https://github.com/ziglang/zig.git
synced 2025-12-11 08:43:09 +00:00
* add support for compiling Objective-C++ code Prior to this change, calling `step.addCSourceFiles` with Obj-C++ file extensions (`.mm`) would result in an error due to Zig not being aware of that extension. Clang supports an `-ObjC++` compilation mode flag, but it was only possible to use if you violated standards and renamed your `.mm` Obj-C++ files to `.m` (Obj-C) to workaround Zig being unaware of the extension. This change makes Zig aware of `.mm` files so they can be compiled, enabling compilation of projects such as [Google's Dawn WebGPU](https://dawn.googlesource.com/dawn/) using a `build.zig` file only. Helps hexops/mach#21 Signed-off-by: Stephen Gutekanst <stephen@hexops.com> * test/standalone: add ObjC++ compilation/linking test Based on the existing objc example, just tweaked for ObjC++. Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
15 lines
320 B
Plaintext
15 lines
320 B
Plaintext
#import "Foo.h"
|
|
#import <assert.h>
|
|
#include <iostream>
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
@autoreleasepool {
|
|
Foo *foo = [[Foo alloc] init];
|
|
NSString *result = [foo name];
|
|
std::cout << "Hello from C++ and " << [result UTF8String];
|
|
assert([result isEqualToString:@"Zig"]);
|
|
return 0;
|
|
}
|
|
}
|