Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
adam-wolski opened this issue Nov 1, 2021 · 4 comments
Open

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

adam-wolski opened this issue Nov 1, 2021 · 4 comments

Comments

@adam-wolski
Copy link
Contributor

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.

@Phyronnaz
Copy link
Owner

Phyronnaz commented Nov 1, 2021

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 :)

@adam-wolski
Copy link
Contributor Author

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 😃

@ScottKirvan
Copy link

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!

@adam-wolski
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants