From 8e204b2d677c258ee64510ee7e1363371a8f5ce8 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Wed, 10 May 2017 16:52:50 +0300 Subject: [PATCH 1/2] =?UTF-8?q?[lumped=20builds]=20Only=20define=20=5FCRT?= =?UTF-8?q?=5FSECURE=5FNO=5FWARNINGS=20if=20it=E2=80=99s=20not=20defined?= =?UTF-8?q?=20yet.=20When=20glslang=20is=20built=20with=20some=20other=20b?= =?UTF-8?q?uild=20system=20and=20lumped/unity=20builds=20are=20used,=20wit?= =?UTF-8?q?hout=20the=20checks=20this=20would=20get=20=E2=80=9Cmacro=20is?= =?UTF-8?q?=20being=20redefined=E2=80=9D=20warnings/errors.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- StandAlone/StandAlone.cpp | 2 ++ glslang/MachineIndependent/preprocessor/Pp.cpp | 2 ++ glslang/MachineIndependent/preprocessor/PpAtom.cpp | 2 ++ glslang/MachineIndependent/preprocessor/PpScanner.cpp | 2 ++ glslang/MachineIndependent/preprocessor/PpTokens.cpp | 4 +++- 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index 3faadecf..76af8fe3 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -35,7 +35,9 @@ // // this only applies to the standalone wrapper, not the front end in general +#ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS +#endif #include "ResourceLimits.h" #include "Worklist.h" diff --git a/glslang/MachineIndependent/preprocessor/Pp.cpp b/glslang/MachineIndependent/preprocessor/Pp.cpp index e71e79c4..293ada6c 100644 --- a/glslang/MachineIndependent/preprocessor/Pp.cpp +++ b/glslang/MachineIndependent/preprocessor/Pp.cpp @@ -76,7 +76,9 @@ TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \****************************************************************************/ +#ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS +#endif #include #include diff --git a/glslang/MachineIndependent/preprocessor/PpAtom.cpp b/glslang/MachineIndependent/preprocessor/PpAtom.cpp index 52df3b02..06c2333e 100644 --- a/glslang/MachineIndependent/preprocessor/PpAtom.cpp +++ b/glslang/MachineIndependent/preprocessor/PpAtom.cpp @@ -76,7 +76,9 @@ TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \****************************************************************************/ +#ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS +#endif #include #include diff --git a/glslang/MachineIndependent/preprocessor/PpScanner.cpp b/glslang/MachineIndependent/preprocessor/PpScanner.cpp index e72efc04..cee45ce7 100644 --- a/glslang/MachineIndependent/preprocessor/PpScanner.cpp +++ b/glslang/MachineIndependent/preprocessor/PpScanner.cpp @@ -76,7 +76,9 @@ TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \****************************************************************************/ +#ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS +#endif #include #include diff --git a/glslang/MachineIndependent/preprocessor/PpTokens.cpp b/glslang/MachineIndependent/preprocessor/PpTokens.cpp index 7fa06a5a..4baf99e0 100644 --- a/glslang/MachineIndependent/preprocessor/PpTokens.cpp +++ b/glslang/MachineIndependent/preprocessor/PpTokens.cpp @@ -80,8 +80,10 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // For recording and playing back the stream of tokens in a macro definition. // -#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) +#ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS +#endif +#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) #define snprintf sprintf_s #endif From 23d3c712bc35d470e2b675213dd8916ad000f226 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Wed, 10 May 2017 16:58:38 +0300 Subject: [PATCH 2/2] [lumped builds] Add include guards (#pragma once) to header files that did not have any. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The codebase seems to use both “#pragma once“ approach, and “#ifndef / #define” approach, so I picked pragma once as that one is less typing & less brittle. When glslang is built with some other build system and lumped/unity builds are used, without the include guards some headers would get included multiple times, leading to duplicate declaration errors. --- SPIRV/GlslangToSpv.h | 2 ++ SPIRV/doc.h | 2 ++ glslang/MachineIndependent/LiveTraverser.h | 2 ++ glslang/MachineIndependent/RemoveTree.h | 2 ++ glslang/MachineIndependent/ScanContext.h | 2 ++ glslang/MachineIndependent/gl_types.h | 2 ++ glslang/MachineIndependent/propagateNoContraction.h | 2 ++ 7 files changed, 14 insertions(+) diff --git a/SPIRV/GlslangToSpv.h b/SPIRV/GlslangToSpv.h index 11e22f58..aba48a38 100644 --- a/SPIRV/GlslangToSpv.h +++ b/SPIRV/GlslangToSpv.h @@ -32,6 +32,8 @@ // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. +#pragma once + #if _MSC_VER >= 1900 #pragma warning(disable : 4464) // relative include path contains '..' #endif diff --git a/SPIRV/doc.h b/SPIRV/doc.h index 7dcc51dd..710ca1a5 100644 --- a/SPIRV/doc.h +++ b/SPIRV/doc.h @@ -36,6 +36,8 @@ // Parameterize the SPIR-V enumerants. // +#pragma once + #include "spirv.hpp" #include diff --git a/glslang/MachineIndependent/LiveTraverser.h b/glslang/MachineIndependent/LiveTraverser.h index 029c24a8..7333bc96 100644 --- a/glslang/MachineIndependent/LiveTraverser.h +++ b/glslang/MachineIndependent/LiveTraverser.h @@ -33,6 +33,8 @@ // POSSIBILITY OF SUCH DAMAGE. // +#pragma once + #include "../Include/Common.h" #include "reflection.h" #include "localintermediate.h" diff --git a/glslang/MachineIndependent/RemoveTree.h b/glslang/MachineIndependent/RemoveTree.h index 507307e4..1ed01562 100644 --- a/glslang/MachineIndependent/RemoveTree.h +++ b/glslang/MachineIndependent/RemoveTree.h @@ -32,6 +32,8 @@ // POSSIBILITY OF SUCH DAMAGE. // +#pragma once + namespace glslang { void RemoveAllTreeNodes(TIntermNode*); diff --git a/glslang/MachineIndependent/ScanContext.h b/glslang/MachineIndependent/ScanContext.h index 1d86348e..608ae067 100644 --- a/glslang/MachineIndependent/ScanContext.h +++ b/glslang/MachineIndependent/ScanContext.h @@ -38,6 +38,8 @@ // sits between the preprocessor scanner and parser. // +#pragma once + #include "ParseHelper.h" namespace glslang { diff --git a/glslang/MachineIndependent/gl_types.h b/glslang/MachineIndependent/gl_types.h index d7cb31fe..ae00ae57 100644 --- a/glslang/MachineIndependent/gl_types.h +++ b/glslang/MachineIndependent/gl_types.h @@ -21,6 +21,8 @@ ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ +#pragma once + #define GL_FLOAT 0x1406 #define GL_FLOAT_VEC2 0x8B50 #define GL_FLOAT_VEC3 0x8B51 diff --git a/glslang/MachineIndependent/propagateNoContraction.h b/glslang/MachineIndependent/propagateNoContraction.h index 3412c85d..8521ad7d 100644 --- a/glslang/MachineIndependent/propagateNoContraction.h +++ b/glslang/MachineIndependent/propagateNoContraction.h @@ -37,6 +37,8 @@ // propagate 'noContraction' qualifier. // +#pragma once + #include "../Include/intermediate.h" namespace glslang {