-
Notifications
You must be signed in to change notification settings - Fork 947
Description
I can't compile when glslang is used inside a (C++20) module. This is my module implementation unit:
module;
#include <glslang/Public/ResourceLimits.h>
#include <glslang/Public/ShaderLang.h>
#include <glslang/SPIRV/GlslangToSpv.h>
module ShaderCompiler;
import std;This is a situation where standard library (std) is both included and imported, which yields a lot of redefinition errors, see error list:
xstring(2323, 52): [C2572] 'std::basic_string': redefinition of default argument: parameter 1
xstring(2323, 87): [C2572] 'std::basic_string': redefinition of default argument: parameter 2
vector(435, 49): [C2572] 'std::vector': redefinition of default argument: parameter 1
xtr1common(47, 47): [C2572] 'std::enable_if': redefinition of default argument: parameter 1
xstring(896, 52): [C2572] 'std::basic_string_view': redefinition of default argument: parameter 1
iosfwd(190, 52): [C2572] 'std::basic_stringbuf': redefinition of default argument: parameter 1
[...]
I guess this means that with modularized C++, one must use the C interface of glslang.?
EDIT
Even when I use the C interface (I downloaded a compiled Window release), it seems the lib files (glslang.lib, SPIRV.lib, etc.) were compiled in a manner incompatible with my modularized build, I get some nasty linking errors:
Error LNK2038 : mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in MyProject.lib(std.ixx.obj)
Error LNK2038 : mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in MyProject.lib(std.ixx.obj)
[...]
I unfortunately don't have any experience with porting existing libraries to C++ modules, so it would seem I have to use an approach similar to GLM (https://github.com/g-truc/glm/blob/master/glm/glm.cppm), or compile everything from source by manually converting every single glslang header file into a module interface unit.