gpt4 book ai didi

ios - 错误 : symbol 'xxx' is multiply defined

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:00:14 27 4
gpt4 key购买 nike

我在我的代码中添加了多个 Metal 着色器,现在我得到:

Error: symbol '<shader name>' is multiply defined
Command /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/bin/metallib failed with exit code 1

我不在任何地方包含 .metal 文件(XCode 负责编译本身)并且我无法将 inlinestatic 添加到函数,那有什么问题呢?

最佳答案

在头文件中定义函数也有问题。我以为我可以内联它们,但似乎我只能声明它们。

例如,我有这个头文件,

// ShaderMath.h
#pragma once
using namespace metal;
float4 conjugate(const float4 q);

float4 conjugate(const float4 q) {
return float4( -q.xyz, q.w );
}

如果我在多个 Metal 文件中包含此 header ,我会收到“多重定义”错误。但是,如果我将定义移动到 .metal 文件,那么它就可以工作。头文件只是,

// ShaderMath.h
#pragma once
using namespace metal;
float4 conjugate(const float4 q);

和 Metal 锉,

// ShaderMath.metal
#include <metal_stdlib>
#include "ShaderMath.h"
using namespace metal;
float4 conjugate(const float4 q) {
return float4( -q.xyz, q.w );
}

我希望这可以帮助其他遇到同样问题的人。

关于ios - 错误 : symbol 'xxx' is multiply defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31953680/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com