如何摆脱 Xcode 中的“未知类型名称‘__declspec’”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35192700/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:29:59  来源:igfitidea点击:

How to get rid of "Unknown type name '__declspec'" error in Xcode

iosxcodeunity3dgoogle-cardboard

提问by Pro Q

I tried to build and run my first project for Google Cardboard in Xcode.

我尝试在 Xcode 中为 Google Cardboard 构建和运行我的第一个项目。

I first encountered something that basically said my signature was incorrect and asked me to sign in so that the computer could fix it (which it seemed to). (I include this info in case it is related to the error in some way.)

我第一次遇到的东西基本上是说我的签名不正确,并要求我登录以便计算机可以修复它(似乎是这样)。(我包含此信息,以防它以某种方式与错误有关。)

I then encountered the error Unknown type name '__declspec'and have no idea how to fix it.

然后我遇到了错误Unknown type name '__declspec',不知道如何修复它。

This issue is also found herebut there are no answers to it. A Google searchyielded about 50 results, so it seems relatively uncommon.

这个问题也在这里找到但没有答案。一个谷歌搜索产生约50个结果,因此它似乎比较少见。

What would be my best course of action?

我最好的行动方针是什么?

采纳答案by Pro Q

Unity just released a new version, 5.3.2, to deal with this issue.

Unity 刚刚发布了一个新版本 5.3.2 来解决这个问题。

回答by Almo

I have a fix for if you can't upgrade to the Unity version that fixes this.

如果您无法升级到修复此问题的 Unity 版本,我有一个修复程序。

Find the 3 files in the Unity application called il2cpp-codegen.h. For example, on Mac Unity, they're here:

在名为 il2cpp-codegen.h 的 Unity 应用程序中找到 3 个文件。例如,在 Mac Unity 上,它们在这里:

/Applications/Unity5.1.4/Unity.app/Contents/PlaybackEngines/WebGLSupport/BuildTools/Libraries/libil2cpp/include/codegen/il2cpp-codegen.h
/Applications/Unity5.1.4/Unity.app/Contents/PlaybackEngines/iossupport/il2cpp/libil2cpp/include/codegen/il2cpp-codegen.h
/Applications/Unity5.1.4/Unity.app/Contents/Frameworks/il2cpp/libil2cpp/codegen/il2cpp-codegen.h

Find this line in those:

在那些中找到这一行:

NORETURN static void il2cpp_codegen_raise_exception (Il2CppCodeGenException *ex)

Delete the "NORETURN" from each, and save the files. It should work now.

从每个删除“NORETURN”,并保存文件。它现在应该可以工作了。

回答by tiguero

I had a similar issue in a library that embed a C++ dll.

我在嵌入 C++ dll 的库中遇到了类似的问题。

If you don't want to upgrade I believe you can replace:

如果您不想升级,我相信您可以替换:

#define NORETURN __declspec(noreturn)

by

经过

#define NORETURN __attribute__((noreturn))

回答by Waqar Iqbal

For each file that is throwing error, one should delete NORETURNfrom those lines only.

对于每个抛出错误的文件,只应从这些行中删除NORETURN

But sometimes it's not NORETURNthe issue, but one would have to delete IL2CPP_NO_INLINE.

但有时这不是NORETURN问题,而是必须删除IL2CPP_NO_INLINE

This should resolve the issue.

这应该可以解决问题。