-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior
Description
Zig Version
0.15.2
Steps to Reproduce and Observed Behavior
The build failed silently.
build.zig
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const hello = b.addObject(.{
.name = "hello",
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libcpp = true,
}),
});
hello.root_module.addCSourceFiles(.{
.files = &.{
"foo.cpp",
"bar.cpp",
},
});
hello.root_module.addIncludePath(.{
.cwd_relative = ".",
});
const exe = b.addExecutable(.{
.name = "lca",
.root_module = b.createModule(.{
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
.link_libcpp = true,
.imports = &.{},
}),
// .use_llvm = true,
});
exe.root_module.addObject(hello);
exe.root_module.addIncludePath(.{
.cwd_relative = ".",
});
b.installArtifact(exe);
}foo.cpp
#include "foo.h"
#include <string>
#include <vector>
void foo() { std::vector<std::string> keys{"xxx", "yyy"}; }foo.h
#ifndef _FOO_H_
#define _FOO_H_
#ifdef __cplusplus
extern "C" {
#endif
void foo();
#ifdef __cplusplus
}
#endif
#endifbar.cpp (similar to foo.cpp)
#include "bar.h"
#include <string>
#include <vector>
void bar() { std::vector<std::string> keys{"xxx", "yyy"}; }bar.h
#ifndef _BAR_H_
#define _BAR_H_
#ifdef __cplusplus
extern "C" {
#endif
void bar();
#ifdef __cplusplus
}
#endif
#endifmain.zig
const std = @import("std");
pub fn main() void {
std.debug.print("Hello, World!\n", .{});
}
Using .use_llvm=true or removing one of foo.cpp and bar.cpp from build.zig can fix this.
Expected Behavior
No error
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior

