D is trying to parse C and C++ inside strings

Hipreme msnmancini at hotmail.com
Sat Mar 18 03:00:46 UTC 2023


I'm writing Metal shaders right now on my engine and I got the 
following warning (I use warn as errors so this is giving me nuts 
as I'll need to refactor my code to hide that string)


```d
string getCoolString()
{
     return q{
         #include <metal_stdlib>
         #include <simd/simd.h>
         using namespace metal;
     };
}

void main()
{
     writeln(getCoolString);
}
```

In the run.dlang, I get the following error:

```
Error: d++ cannot find file path for header 'metal_stdlib'
Error Program exited with code 1
```

In my code, I'm getting the following error:

```d
override string getFrameBufferVertex()
     {
         return q{
#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct VertexInput
{
     float2 vPosition;
     float2 vTexST;
};
struct FragmentInput
{
     ///Unused
     float4 position [[position]];
     float2 inTexST;
};

vertex FragmentInput vertex_main(
     uint vertexID [[vertex_id]],
     VertexInput* input [[buffer(1)]]
)
{
     FragmentInput out;
     out.position = float4(input[vertexID].vPosition, 0.0, 1.0);
     out.inTexST = input[vertexID].vTexST;
     return out;
}
};
     }

```
modules/renderer/source/hip/hiprenderer/backend/metal/mtlshader.d(104,9): Warning: C preprocessor directive `#include` is not supported

This looks like related to use token string.


More information about the Digitalmars-d mailing list