Metal-CPP Errors

After following the instructions here:

https://developer.apple.com/metal/cpp/

I attempted building my project and Xcode presented several errors. In essence it's complaining about some redeclarations in the Metal-CPP headers.

NSBundle.hpp and NSError.hpp are included in the metal-cpp/foundation directory from the metal-cpp download.

Any help in getting these issues resolved is appreciated.

Thanks!

Answered by Graphics and Games Engineer in 827182022

Are you including both Foundation.h and Foundation.hpp in the same file?

In general, you cannot mix ObjC classes with Metal-CPP classes in the same file. There are a few exceptions here, like with view classes..

Are you including both Foundation.h and Foundation.hpp in the same file?

In general, you cannot mix ObjC classes with Metal-CPP classes in the same file. There are a few exceptions here, like with view classes..

Thanks for the reply!

I found that the issue was caused by including these lines:

#define NS_PRIVATE_IMPLEMENTATION
#define MTL_PRIVATE_IMPLEMENTATION
#define MTK_PRIVATE_IMPLEMENTATION
#define CA_PRIVATE_IMPLEMENTATION

in my header. I moved them to an implementation file, .cpp and the issues cleared up.

Metal-CPP Errors
 
 
Q