Including header files in metal source files

So, I have a lot of uniforms in shader code, for which I make multiple structs. At places I have to define the same struct twice, once which can be used by my C++ code, and another by my metal shaders. I was trying to consolidate those structures into a separate header file, and include it in both the .metal file and the C++ source files. But turns out, the .metal files fails to recognise the structures defined in .h file, and fail during compilation.

Is there any guideline on how these can be combined and save me from having two definitions? Or am I doing something wrong?


struct Metal_Transformation
    float a;


#include "MetalShaderStruct.h"

vertex float4 myShader(const device Metal_Transformation* transform[[buffer(0) ]])


Error: unknown type name 'Metal_Transformation'

Is this an allowed way to do this?? Am I missing something??

Just to clarify for the downvote, I have tried looking for this answer, but I cannot seem to find any place where this is specified, if you can not include header files, that too when it is given that metal adheres to C++14 standards.