有没有办法让纯c文件使用<Metal/Metah.h>?
Is there a method to allow pure c file to use <Metal/Metah.h>?
也就是说,ios的metal可以用在纯c文件中吗?感谢您的审阅。
Metal API 是 Objective-C,但这不应该成为问题,因为您可以在 Objective-C 实现文件中提供 C 函数,因此其余的基于 C 的代码可以调用这些函数。
例如(我不知道金属API,所以这是胡言乱语):
metalapi.h:
// This is a C function...
extern int doThingWithMetal(int someParam, const char *otherParam);
metalapi.m:
#import <Metal/Metal.h>
// ... implemented in Objective-C
int doThingWithMetal(int someParam, const char *otherParam)
{
return [someMetalClass someMethod:someParam] == SOME_VALUE ? 0 : 1;
}
otherfile.c
#include "metalapi.h"
....
if (doThingWithMetal(1, "Hello") == 0) {
...
}
也就是说,ios的metal可以用在纯c文件中吗?感谢您的审阅。
Metal API 是 Objective-C,但这不应该成为问题,因为您可以在 Objective-C 实现文件中提供 C 函数,因此其余的基于 C 的代码可以调用这些函数。
例如(我不知道金属API,所以这是胡言乱语):
metalapi.h:
// This is a C function...
extern int doThingWithMetal(int someParam, const char *otherParam);
metalapi.m:
#import <Metal/Metal.h>
// ... implemented in Objective-C
int doThingWithMetal(int someParam, const char *otherParam)
{
return [someMetalClass someMethod:someParam] == SOME_VALUE ? 0 : 1;
}
otherfile.c
#include "metalapi.h"
....
if (doThingWithMetal(1, "Hello") == 0) {
...
}