-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Visual Studio and XCode Warnings #618
Conversation
clang emits another warning about an unused private field: EDIT: |
1f8c320
to
05fa3f5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
;)
rwengine/src/ai/AIGraph.cpp
Outdated
@@ -19,7 +19,7 @@ AIGraph::~AIGraph() { | |||
|
|||
void AIGraph::createPathNodes(const glm::vec3& position, | |||
const glm::quat& rotation, PathData& path) { | |||
size_t startIndex = nodes.size(); | |||
std::uint32_t startIndex = static_cast<std::uint32_t>(nodes.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto
rwengine/src/audio/SoundSource.cpp
Outdated
@@ -248,7 +248,7 @@ struct InputData { | |||
/// to buffer. | |||
static int read_packet(void* opaque, uint8_t* buf, int buf_size) { | |||
auto* input = reinterpret_cast<InputData*>(opaque); | |||
buf_size = FFMIN(buf_size, input->size); | |||
buf_size = FFMIN(buf_size, static_cast<int>(input->size)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here can be used std::fmin
instead of this ugly macro. IIRC it's clang warn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::fmin
is for floating points. That would create new warnings.
std::min
has only templates for arguments of the same type.
@@ -58,15 +58,15 @@ WaterRenderer::WaterRenderer(GameRenderer* renderer) { | |||
void WaterRenderer::setWaterTable(const float* waterHeights, const unsigned int nHeights, | |||
const uint8_t* tiles, const unsigned int nTiles) { | |||
// Determine the dimensions of the input tiles | |||
int edgeNum = sqrt(nTiles); | |||
unsigned int edgeNum = static_cast<unsigned int>(sqrt(nTiles)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto
float tileSize = WATER_WORLD_SIZE / edgeNum; | ||
glm::vec2 wO{-WATER_WORLD_SIZE / 2.f, -WATER_WORLD_SIZE / 2.f}; | ||
|
||
std::vector<glm::vec3> vertexData; | ||
|
||
for (int x = 0; x < edgeNum; x++) { | ||
for (unsigned int x = 0; x < edgeNum; x++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (auto x = 0u; x < edgeNum; x++) {
int xi = x * WATER_HQ_DATA_SIZE; | ||
for (int y = 0; y < edgeNum; y++) { | ||
for (unsigned int y = 0; y < edgeNum; y++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (auto y = 0u; y < edgeNum; y++) {
rwviewer/models/IMGArchiveModel.hpp
Outdated
@@ -14,15 +13,15 @@ class IMGArchiveModel : public QAbstractListModel { | |||
: QAbstractListModel(parent), archive(archive) { | |||
} | |||
|
|||
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; | |||
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use override
there's no need for virtual
.
efc4872
to
cc48a70
Compare
rwengine/src/render/ViewFrustum.hpp
Outdated
@@ -32,9 +32,9 @@ class ViewFrustum { | |||
} | |||
|
|||
void update(const glm::mat4& proj) { | |||
for (size_t i = 0; i < 6; ++i) { | |||
for (unsigned int i = 0; i < 6; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (auto i = 0u; i < 6; ++i) {
rwengine/src/render/TextRenderer.cpp
Outdated
@@ -284,7 +284,7 @@ void TextRenderer::renderText(const TextRenderer::TextInfo& ti, | |||
// will need to be wrapped | |||
if (ti.wrapX > 0 && coord.x > 0.f && !std::isspace(c)) { | |||
auto wend = std::find_if(std::begin(text) + i, std::end(text), | |||
[](char x) { return std::isspace(x); }); | |||
[](GameStringChar c) { return std::isspace(c); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be here used auto
?
a7bee5e
to
26a5d50
Compare
6fe0bdd
to
413cb50
Compare
.appveyor.yml
Outdated
@@ -22,7 +22,8 @@ platform: | |||
|
|||
configuration: | |||
# - Debug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused configurations
cmake/ctest/build.ctest
Outdated
if(CC) | ||
list(APPEND _CONGIGURE_OPTIONS "-DCMAKE_C_COMPILER=${CC}") | ||
endif() | ||
if(CXX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't CMake respect the environment variables already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, and ctest does too. I overcomplicated things because at the start of a travis build, there is an explicit export CC=gcc and export CXX=g++
cmake_configure.cmake
Outdated
if(MSVC_PARALLEL_BUILD) | ||
target_compile_options(rw_interface | ||
INTERFACE | ||
"/MP" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be configurable? Can we put it in the default flags above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a convenience for me to see what source emitted the bullet warnings. These warnings messages did not contain any reference to what source included them. But I guess its use is gone.
rwcore/gl/DrawBuffer.cpp
Outdated
glVertexAttribPointer(vaoindex, at.size, at.type, GL_TRUE, at.stride, | ||
reinterpret_cast<GLvoid*>(at.offset)); | ||
glVertexAttribPointer(vaoindex, static_cast<GLint>(at.size), at.type, GL_TRUE, at.stride, | ||
reinterpret_cast<void*>(static_cast<size_t>(at.offset))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make offset
size_t
?
rwcore/loaders/LoaderDFF.cpp
Outdated
@@ -259,7 +259,7 @@ GeometryPtr LoaderDFF::readGeometry(const RWBStream &stream) { | |||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, geom->EBO); | |||
|
|||
size_t icount = std::accumulate( | |||
geom->subgeom.begin(), geom->subgeom.end(), 0u, | |||
geom->subgeom.begin(), geom->subgeom.end(), static_cast<size_t>(0u), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size_t{0u}
is shorter
private: | ||
GameWorld* m_world; | ||
const ViewCamera& m_camera; | ||
float m_renderAlpha; | ||
GLuint m_errorTexture; | ||
#ifdef RW_DEBUG | ||
GLuint m_errorTexture = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks completely unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was. Removed.
e56bdab
to
5df0d05
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
5df0d05
to
13c1169
Compare
Fixes clang warnings about unused private fields: -Wunused-private-field
warning C4305: 'argument': truncation from 'double' to 'const btScalar'
This warning displays while building OpenRW in Visual Studio 2017 IDE
External projects do not need boost, glm or bullet specific options. Though, we do want to enable sanitizers and coverage on them.
b979a9a
to
85080c8
Compare
85080c8
to
a1343e6
Compare
I've disabled SIMD for glm by setting the compile definition |
LGTM |
a1343e6
to
0923eca
Compare
This pr fixes all Visual Studio and XCode warnings created by our code.
Most warnings were caused by:
Warnings remaining on Visual Studio:
There is still a warning caused by Bullet, which is fixed upstream and will be gone in the next bullet release.I've explicitly disabled these warnings using
#pragma
's. This commit can be reverted once a fixed version of bullet is released.Also:
#pragma once
'swarning: missing braces around initializer [-Wmissing-braces]
warnings of xcodeCheck out the green at https://my.cdash.org/index.php?project=OpenRW