是否可以在 .metal 文件中包含标准 C++ 库?
Is it possible to include a standard c++ library in a .metal file?
我目前正在为 iOS 中的图像处理应用程序开发金属内核(在 .metal 文件中)。我想包含一些标准的 C++ 库(例如 <iostream>
或 <algorithm>
),但 Xcode 似乎不允许这样做(我在编译时收到“找不到文件”错误.
有没有人运行遇到过这类问题?在不使用一些基本库的情况下能够在金属中编写自定义内核似乎很荒谬,这让我认为必须有一个答案。
让我们看看documentation是怎么说的:
The C++ standard library must not be used in the Metal shading language code. Instead of using the C++ standard library, Metal uses its own standard library, which is described in Metal Standard Library.
所以不,这是不可能的。请改用金属标准库。
我目前正在为 iOS 中的图像处理应用程序开发金属内核(在 .metal 文件中)。我想包含一些标准的 C++ 库(例如 <iostream>
或 <algorithm>
),但 Xcode 似乎不允许这样做(我在编译时收到“找不到文件”错误.
有没有人运行遇到过这类问题?在不使用一些基本库的情况下能够在金属中编写自定义内核似乎很荒谬,这让我认为必须有一个答案。
让我们看看documentation是怎么说的:
The C++ standard library must not be used in the Metal shading language code. Instead of using the C++ standard library, Metal uses its own standard library, which is described in Metal Standard Library.
所以不,这是不可能的。请改用金属标准库。