clang/gcc: enable a bunch more warnings (#91)

* clang/gcc: enable -pedantic warnings

* suppress a GCC-specific warning in stb_image

* And some clang-specific warnings

* -Wconversion (clang) -Wold-style-cast (clang+gcc)

and fix a few warnings that show up with these (and a few more with
-Wconversion on gcc, even though that's not enabled by default)

* bunch more warnings

* fixes

* remove merge error
This commit is contained in:
Kai Ninomiya
2017-07-21 17:00:22 -07:00
committed by GitHub
parent 159bade5f5
commit 78c8b837ea
29 changed files with 85 additions and 52 deletions

View File

@@ -51,3 +51,7 @@ add_library(utils STATIC ${UTILS_SOURCES})
target_link_libraries(utils nxt_backend shaderc nxtcpp nxt)
target_include_directories(utils PUBLIC ${SRC_DIR})
NXTInternalTarget("" utils)
if(NOT MSVC)
# allow C-style casts -- for shaderc
set_property(TARGET utils APPEND PROPERTY COMPILE_OPTIONS "-Wno-old-style-cast")
endif()

View File

@@ -50,8 +50,13 @@ namespace utils {
return;
}
size_t size = (result.cend() - result.cbegin());
builder.SetSource(static_cast<uint32_t>(size), result.cbegin());
// result.cend and result.cbegin return pointers to uint32_t.
const uint32_t* resultBegin = result.cbegin();
const uint32_t* resultEnd = result.cend();
// So this size is in units of sizeof(uint32_t).
ptrdiff_t resultSize = resultEnd - resultBegin;
// SetSource takes data as uint32_t*.
builder.SetSource(static_cast<uint32_t>(resultSize), result.cbegin());
#ifdef DUMP_SPIRV_ASSEMBLY
{

View File

@@ -25,11 +25,11 @@
namespace utils {
#if defined(NXT_PLATFORM_WINDOWS)
void USleep(int usecs) {
void USleep(unsigned int usecs) {
Sleep(static_cast<DWORD>(usecs / 1000));
}
#elif defined(NXT_PLATFORM_POSIX)
void USleep(int usecs) {
void USleep(unsigned int usecs) {
usleep(usecs);
}
#else

View File

@@ -14,6 +14,6 @@
namespace utils {
void USleep(int usecs);
void USleep(unsigned int usecs);
}