不支持的体系结构-Metal和Swift之间的共享枚举

问题描述 投票:4回答:1

我尝试在metal和我的swift项目之间共享我在头文件中定义的枚举:

#ifndef SharedIndizes_h
#define SharedIndizes_h
#import <Foundation/Foundation.h>

#endif /* SharedIndizes_h */

typedef NS_ENUM(NSInteger, VertexAttribute)
{
    VertexAttributePosition = 0,
    VertexAttributeNormal  = 1,
};
#include <metal_stdlib>
#import "ExchangeTypes/SharedIndizes.h"
using namespace metal;

struct VertexIn {
    float3 position [[ attribute(VertexAttributePosition) ]];
    float3 normal [[ attribute(VertexAttributeNormal) ]];
};
vertexDescriptor.attributes[VertexAttribute.position.rawValue]
vertexDescriptor.attributes[VertexAttribute.normal.rawValue]

但是我得到的是一些意外的错误:

  • 不支持的架构

  • 未知类型名称'_int64_t'

  • 未知类型名称'_int32_t'

  • ...

从我的金属文件中删除#import "ExchangeTypes/SharedIndizes.h"也会删除错误。

swift metal
1个回答
0
投票
添加此:

#ifndef SharedIndizes_h #define SharedIndizes_h #ifdef __METAL_VERSION__ #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type #define NSInteger metal::int32_t #else #import <Foundation/Foundation.h> #endif /* SharedIndizes_h */ typedef NS_ENUM(NSInteger, VertexAttribute) { VertexAttributePosition = 0, VertexAttributeNormal = 1, };

© www.soinside.com 2019 - 2024. All rights reserved.