address space qualifier

今天调试一段第三方代码时出现这样的错误

pointer type must have explicit address space qualifier

出错的是一个c语言的.h文件,不记得c语言里需要address space qualifier,检查后发现这个.h被.metal文件引用,查看了一下metal的文档,果然是metal的的语法要求。

Metal shading language限定了指针的使用,必须用device,threadgroup,constant等修饰符来声明,这些修饰符指定了函数变量或参数分配到的内存区域。

详情可参见
Metal-Shading-Language-Specification.pdf

4.2 Address Space Attributes for Variables and Arguments 
The Metal shading language implements address space attributes to specify the region of
memory where a function variable or argument is allocated. These attributes describe disjoint
address spaces for variables:
• device (for more details, see section 4.2.1)
• threadgroup (see section 4.2.2)
• threadgroup_imageblock (see section 4.2.3)
• constant (see section 4.2.4)
• thread (see section 4.2.5)
All arguments to a graphics or kernel function that are a pointer or reference to a type must be
declared with an address space attribute. For graphics functions, an argument that is a pointer
or reference to a type must be declared in the device or constant address space. For kernel
functions, an argument that is a pointer or reference to a type must be declared in the device,
threadgroup, threadgroup_imageblock, or constant address space.

你可能感兴趣的:(address space qualifier)