HLSLMaterial icon indicating copy to clipboard operation
HLSLMaterial copied to clipboard

Includes are added even if they are guarded by #ifdef-s

Open adam-wolski opened this issue 3 years ago • 4 comments

When parsing includes in hlsl file all of them are added even if they are guarded by failed #ifdef

#include "header_a.ush"

#ifndef SOMEDEF
#include "header_b.ush"
#endif

Right now both header_a and header_b are included and this leads to compilation errors.

adam-wolski avatar Nov 01 '21 08:11 adam-wolski

Mmh, not sure that's easily fixable.

Where is SOMEDEF defined here? In header_a?

I'd like to make sure I fully understand the context :)

Phyronnaz avatar Nov 01 '21 08:11 Phyronnaz

Yes this define is from other header.

It's not that big of a problem right now. As a workaround I do such includes in function body or in other headers.

I don't see easy fix for that and I'm not sure if it's worth fixing.

I've added issue to see what's your stance on this 😃

adam-wolski avatar Nov 01 '21 09:11 adam-wolski

Hi! Just a thought here, but it would take some refactoring: You could run an external c pre-processor on the file. In gcc, you use -E, and in msdev, it's /P (I think - I haven't done this in a while). There may be a decent c preprocessor that you could build in.

As an aside: How do you set your include paths? I've been trying to figure this out for 2 days and I can't get includes to work - Thanks! Love this thing!

ScottKirvan avatar Nov 27 '21 06:11 ScottKirvan

As an aside: How do you set your include paths? I've been trying to figure this out for 2 days and I can't get includes to work

You need to use AddShaderSourceDirectoryMapping in module that loads in early enough LoadingPhase like PostConfigInit

adam-wolski avatar Nov 29 '21 16:11 adam-wolski