Advertisement

HLSL shader code editor problem: howto manage many includes

Started by January 22, 2021 09:06 AM
0 comments, last by evelyn4you 4 years ago

hi,

i am using Visual Studio Community Version 2019 with HLSL tools extension for shader editing.

Lets consider the following situation.

// definition of a global used structure
Source File A: structure_def.inc
struct Global_used_structure
{
float a;
float b;
}

// B is using it
Source File B: B_using_structure_A.fx
include "structure_def.inc"

Global_used_structure my_point ;

// C is using it
Source File C: C_using_structure_A.fx
include "structure_def.inc"

Global_used_structure my_other_point ;

// D is using it
Source File D: problem_file.fx
include "structure_def.inc"
include “B_using_structure_A.fx”
include “C_using_structure_A.fx”

Global_used_structure my_new_point ;

here i will get error of redefinition of structure because it is included several times.

OK i can change

// definition of a global used structure
Source File A: structure_def.inc
#ifndef Global_used_structure_H
#def Global_used_structure

struct Global_used_structure
{
float a;
float b;
}
#endif

But the problem is that i loose every code sensitive functions e.g. goto definitions and the HLSL tool will show me much errors in the code.

How to solve this.

This topic is closed to new replies.

Advertisement