stdatomic.h not found, for use in swift & metal compute shader

青春壹個敷衍的年華 提交于 2021-02-08 10:10:55

问题


I'm trying to use a struct with an atomic_int for use in a metal compute shader. However, it says I need to import #include "stdatomic.h" - but every time I try, it can't find the file.

#include "stdatomic.h" // 'stdatomic.h' file not found

I'm trying to build my application for macOS Catalina

struct Fitness {
    atomic_int weight; // Declaration of 'atomic_int' must be imported from module 'Darwin.C.stdatomic' before it is required
    ...others...
};
  • I have tried placing a copy of stdatomic.h into my project, but that gives a lot of compilation errors.
  • My struct is defined in a .h header file.
  • The struct is used by both Swift & Metal.
  • I'm using XCode 11.4.

Update: If I #include in a .cpp file it works...why not a header?

Any ideas what is wrong? Can I not do what I want?

来源:https://stackoverflow.com/questions/61001742/stdatomic-h-not-found-for-use-in-swift-metal-compute-shader

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!