Skip to content

Commit

Permalink
Common: include standard headers before doing any defines
Browse files Browse the repository at this point in the history
currently, due to

```c++
\#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) || defined MINGW_HAS_SECURE_API
    #include <basetsd.h>
    #ifndef snprintf
    #define snprintf sprintf_s
    #endif
    #define safe_vsprintf(buf,max,format,args) vsnprintf_s((buf), (max), (max), (format), (args))
```

defining `snprintf` to `sprintf_s` essentially unconditionally, this will break the
stdio.h+cstdio system header for mingw-w64 g++ in msys2 with shaderc
google/shaderc#1065

an alternative change would be
https://raw.githubusercontent.com/shinchiro/mpv-winbuild-cmake/master/packages/glslang-0001-fix-gcc-10.1-error.patch
in which the `|| defined MINGW_HAS_SECURE_API` part is removed

Signed-off-by: Christopher Degawa <ccom@randomderp.com>
  • Loading branch information
1480c1 committed Jul 12, 2020
1 parent 1ee5d1c commit 8486b2e
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions glslang/Include/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
#ifndef _COMMON_INCLUDED_
#define _COMMON_INCLUDED_

#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <list>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#if defined(__ANDROID__) || (defined(_MSC_VER) && _MSC_VER < 1700)
#include <sstream>
Expand Down Expand Up @@ -93,18 +104,6 @@ std::string to_string(const T& val) {
#pragma warning(disable : 4201) // nameless union
#endif

#include <set>
#include <unordered_set>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cassert>

#include "PoolAlloc.h"

//
Expand Down

0 comments on commit 8486b2e

Please sign in to comment.