MSYS2/MinGW with GCC 10.1: scope issues for snprintf, may need explicit cstdio include
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 445
- Avg merge
- 11h 6m
- Merged PRs (30d)
- 6
Description
There have been several issues compiling C++ projects in GCC 10.1 under MSYS2/MinGW recently, usually missing an explicit include of cstd... headers. This project seems to be one of them:
```
[8/82] Building CXX object third_party/glslang/glslang/CMakeFiles/glslang.dir/MachineIndependent/Scan.cpp.o
FAILED: third_party/glslang/glslang/CMakeFiles/glslang.dir/MachineIndependent/Scan.cpp.o
E:\MABS\msys64\mingw32\bin\ccache.exe g++ -DENABLE_HLSL -DENABLE_OPT=1 -DGLSLANG_OSINCLUDE_WIN32 -I../third_party/glslang/glslang/.. -mthreads -mtune=generic -O2 -pipe -Wimplicit-fallthrough -O3 -DNDEBUG -Wextra-semi -w -Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs -Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions -Wno-reorder -fno-rtti -Werror=deprecated-copy -std=c++11 -MD -MT third_party/glslang/glslang/CMakeFiles/glslang.dir/MachineIndependent/Scan.cpp.o -MF third_party\glslang\glslang\CMakeFiles\glslang.dir\MachineIndependent\Scan.cpp.o.d -o third_party/glslang/glslang/CMakeFiles/glslang.dir/MachineIndependent/Scan.cpp.o -c ../third_party/glslang/glslang/MachineIndependent/Scan.cpp
In file included from E:/MABS/msys64/mingw32/i686-w64-mingw32/include/stdio.h:1555,
from E:/MABS/msys64/mingw32/i686-w64-mingw32/include/locale.h:12,
from E:/MABS/msys64/mingw32/include/c++/10.1.0/clocale:42,
from E:/MABS/msys64/mingw32/include/c++/10.1.0/i686-w64-mingw32/bits/c++locale.h:41,
from E:/MABS/msys64/mingw32/include/c++/10.1.0/bits/localefwd.h:40,
from E:/MABS/msys64/mingw32/include/c++/10.1.0/string:43,
from E:/MABS/build/shaderc-git/third_party/glslang/glslang/Include/Common.h:103,
from ../third_party/glslang/glslang/MachineIndependent/../Include/Types.h:43,
from ../third_party/glslang/glslang/MachineIndependent/Scan.cpp:48:
E:/MABS/msys64/mingw32/i686-w64-mingw32/include/sec_api/stdio_s.h:493:23: error: conflicting declaration of 'int sprintf_s(char*, size_t, const char*, ...)' with 'C' linkage
493 | _SECIMP int __cdecl sprintf_s(char *_DstBuf,size_t _DstSize,const char *_Format,...);
| ^~~~~~~~~
In file included from ../third_party/glslang/glslang/MachineIndependent/../Include/Types.h:43,
from ../third_party/glslang/glslang/MachineIndependent/Scan.cpp:48:
E:/MABS/build/shaderc-git/third_party/glslang/glslang/Include/Common.h:56:22: note: previous declaration with 'C++' linkage
56 | #define snprintf sprintf_s
| ^~~~~~~~~
In file included from E:/MABS/msys64/mingw32/include/c++/10.1.0/ext/string_conversions.h:43,
from E:/MABS/msys64/mingw32/include/c++/10.1.0/bits/basic_string.h:6535,
from E:/MABS/msys64/mingw32/include/c++/10.1.0/string:55,
from E:/MABS/build/shaderc-git/third_party/glslang/glslang/Include/Common.h:103,
from ../third_party/glslang/glslang/MachineIndependent/../Include/Types.h:43,
from ../third_party/glslang/glslang/MachineIndependent/Scan.cpp:48:
E:/MABS/msys64/mingw32/include/c++/10.1.0/cstdio:175:11: error: 'snprintf' has not been declared in '::'
175 | using ::snprintf;
| ^~~~~~~~
E:/MABS/msys64/mingw32/include/c++/10.1.0/cstdio:185:22: error: 'snprintf' has not been declared in '__gnu_cxx'
185 | using ::__gnu_cxx::snprintf;
| ^~~~~~~~
In file included from ../third_party/glslang/glslang/MachineIndependent/SymbolTable.h:70,
from ../third_party/glslang/glslang/MachineIndependent/Scan.cpp:49:
../third_party/glslang/glslang/MachineIndependent/../Include/InfoSink.h: In member function 'glslang::TInfoSinkBase& glslang::TInfoSinkBase::operator<<(float)':
../third_party/glslang/glslang/MachineIndependent/../Include/InfoSink.h:78:58: error: 'snprintf' was not declared in this scope
78 | snprintf(buf, size, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ? "%f" : "%g", n);
| ^~~~~~~~
../third_party/glslang/glslang/MachineIndependent/../Include/InfoSink.h:40:1: note: 'snprintf' is defined in header ''; did you forget to '#include '?
39 | #include
+++ |+#include
40 |
In file included from ../third_party/glslang/glslang/MachineIndependent/SymbolTable.h:70,
from ../third_party/glslang/glslang/MachineIndependent/Scan.cpp:49:
../third_party/glslang/glslang/MachineIndependent/../Include/InfoSink.h: In member function 'void glslang::TInfoSinkBase::location(const glslang::TSourceLoc&)':
../third_party/glslang/glslang/MachineIndependent/../Include/InfoSink.h:100:9: error: 'snprintf' was not declared in this scope
100 | snprintf(locText, maxSize, ":%d", loc.line);
| ^~~~~~~~
../third_party/glslang/glslang/MachineIndependent/../Include/InfoSink.h:100:9: note: 'snprintf' is defined in header ''; did you forget to '#include '?
In file included from ../third_party/glslang/glslang/MachineIndependent/Scan.cpp:49:
../third_party/glslang/glslang/MachineIndependent/SymbolTable.h: In member function 'bool glslang::TSymbolTableLevel::insert(glslang::TSymbol&, bool)':
../third_party/glslang/glslang/MachineIndependent/SymbolTable.h:414:13: error: 'snprintf' was not declared in this scope
414 | snprintf(buf, 20, "%s%d", AnonymousPrefix, symbol.getAsVariable()->getAnonId());
| ^~~~~~~~
In file included from ../third_party/glslang/glslang/MachineIndependent/Scan.cpp:49:
../third_party/glslang/glslang/MachineIndependent/SymbolTable.h:71:1: note: 'snprintf' is defined in header ''; did you forget to '#include '?
70 | #include "../Include/InfoSink.h"
+++ |+#include
71 |
In file included from ../third_party/glslang/glslang/MachineIndependent/Scan.cpp:57:
../third_party/glslang/glslang/MachineIndependent/preprocessor/PpContext.h: In member function 'int glslang::TPpContext::TokenStream::Token::get(glslang::TPpToken&)':
../third_party/glslang/glslang/MachineIndependent/preprocessor/PpContext.h:265:17: error: 'snprintf' was not declared in this scope
265 | snprintf(ppToken.name, sizeof(ppToken.name), "%s", name.c_str());
| ^~~~~~~~
In file included from ../third_party/glslang/glslang/MachineIndependent/Scan.cpp:57:
../third_party/glslang/glslang/MachineIndependent/preprocessor/PpContext.h:88:1: note: 'snprintf' is defined in header ''; did you forget to '#include '?
87 | #include "PpTokens.h"
+++ |+#include
88 |
ninja: build stopped: subcommand failed.
```
[logs.zip](https://github.com/google/shaderc/files/4633488/logs.zip) collected by media-autobuild suite
Contributor guide
Assessment
This issue has not been assessed yet.