shader-slang / slang

Making it easier to work with shaders
MIT License
1.99k stars 169 forks source link

`None`: defined as constant under Linux #4652

Closed mklefrancois closed 2 months ago

mklefrancois commented 2 months ago

Depending on the order of includes, compiling on Linux, I see this error for all None enum.

Example of the error:

./cmake_build/_deps/slang-src/include/slang.h:1332:9: error: expected identifier before numeric constant
 1332 |         None,                ///< Paths do not map to the file system
      |         ^~~~

I think it would be better to have a different name than None to avoid this issue.

expipiplus1 commented 2 months ago

An alternative might be changing whatever you're including before that is using a preprocessor macro to make None a numeric constant. Is it possible to use a const value, or differently named macro like PROJECTNAME_NONE or NONE? Or #undef NONE before including slang.h?

expipiplus1 commented 2 months ago

In fact, we do exactly this because of these being defined in xlib headers apparently: https://github.com/shader-slang/slang/blob/8fd9e5d89b04020ff65e7ce9e0b43c1081580347/tools/gfx/vulkan/vk-module.h#L22-L28

expipiplus1 commented 2 months ago

As does Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1288686

csyonghe commented 2 months ago

I don't think we should change our code just because some other library out there is being silly.

csyonghe commented 2 months ago

As @expipiplus1 suggested, there are solutions there to workaround the mess caused by X11.h, and it is widely used in many projects. I am closing this issue as won't fix, but if this workaround doesn't work for you, feel free to reopen.