Skip to content

Commit 5cacce7

Browse files
authored
Merge pull request #650 from BastiaanOlij/fix_compile_warnings
2 parents 8d25e04 + 94efe3d commit 5cacce7

File tree

13 files changed

+111
-75
lines changed

13 files changed

+111
-75
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ jobs:
2626
run: |
2727
scons target=release generate_bindings=yes -j $(nproc)
2828
29+
- name: Build test project
30+
run: |
31+
cd test
32+
scons target=release -j $(nproc)
33+
2934
- name: Upload artifact
3035
uses: actions/upload-artifact@v2
3136
with:
@@ -55,6 +60,11 @@ jobs:
5560
run: |
5661
scons target=release generate_bindings=yes -j $env:NUMBER_OF_PROCESSORS
5762
63+
- name: Build test project
64+
run: |
65+
cd test
66+
scons target=release -j $env:NUMBER_OF_PROCESSORS
67+
5868
- name: Upload artifact
5969
uses: actions/upload-artifact@v2
6070
with:
@@ -89,6 +99,11 @@ jobs:
8999
gcc --version
90100
scons target=release generate_bindings=yes use_mingw=yes -j $env:NUMBER_OF_PROCESSORS
91101
102+
#- name: Build test project (TODO currently not supported, leaving uncommented as a reminder to fix this)
103+
# run: |
104+
# cd test
105+
# scons target=release use_mingw=yes -j $env:NUMBER_OF_PROCESSORS
106+
92107
- name: Upload artifact
93108
uses: actions/upload-artifact@v2
94109
with:
@@ -118,6 +133,11 @@ jobs:
118133
run: |
119134
scons target=release generate_bindings=yes -j $(sysctl -n hw.logicalcpu)
120135
136+
- name: Build test project
137+
run: |
138+
cd test
139+
scons target=release -j $(sysctl -n hw.logicalcpu)
140+
121141
static-checks:
122142
name: Static Checks (clang-format)
123143
runs-on: ubuntu-20.04

include/godot_cpp/core/binder_common.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -239,18 +239,18 @@ void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const G
239239
#ifdef DEBUG_ENABLED
240240
if ((size_t)p_argcount > sizeof...(P)) {
241241
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
242-
r_error.argument = sizeof...(P);
242+
r_error.argument = (int32_t)sizeof...(P);
243243
return;
244244
}
245245
#endif
246246

247247
int32_t missing = (int32_t)sizeof...(P) - (int32_t)p_argcount;
248248

249-
int32_t dvs = default_values.size();
249+
int32_t dvs = (int32_t)default_values.size();
250250
#ifdef DEBUG_ENABLED
251251
if (missing > dvs) {
252252
r_error.error = GDNATIVE_CALL_ERROR_TOO_FEW_ARGUMENTS;
253-
r_error.argument = sizeof...(P);
253+
r_error.argument = (int32_t)sizeof...(P);
254254
return;
255255
}
256256
#endif
@@ -274,18 +274,18 @@ void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const,
274274
#ifdef DEBUG_ENABLED
275275
if ((size_t)p_argcount > sizeof...(P)) {
276276
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
277-
r_error.argument = sizeof...(P);
277+
r_error.argument = (int32_t)sizeof...(P);
278278
return;
279279
}
280280
#endif
281281

282282
int32_t missing = (int32_t)sizeof...(P) - (int32_t)p_argcount;
283283

284-
int32_t dvs = default_values.size();
284+
int32_t dvs = (int32_t)default_values.size();
285285
#ifdef DEBUG_ENABLED
286286
if (missing > dvs) {
287287
r_error.error = GDNATIVE_CALL_ERROR_TOO_FEW_ARGUMENTS;
288-
r_error.argument = sizeof...(P);
288+
r_error.argument = (int32_t)sizeof...(P);
289289
return;
290290
}
291291
#endif
@@ -309,18 +309,18 @@ void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const
309309
#ifdef DEBUG_ENABLED
310310
if ((size_t)p_argcount > sizeof...(P)) {
311311
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
312-
r_error.argument = sizeof...(P);
312+
r_error.argument = (int32_t)sizeof...(P);
313313
return;
314314
}
315315
#endif
316316

317317
int32_t missing = (int32_t)sizeof...(P) - (int32_t)p_argcount;
318318

319-
int32_t dvs = default_values.size();
319+
int32_t dvs = (int32_t)default_values.size();
320320
#ifdef DEBUG_ENABLED
321321
if (missing > dvs) {
322322
r_error.error = GDNATIVE_CALL_ERROR_TOO_FEW_ARGUMENTS;
323-
r_error.argument = sizeof...(P);
323+
r_error.argument = (int32_t)sizeof...(P);
324324
return;
325325
}
326326
#endif
@@ -344,18 +344,18 @@ void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const,
344344
#ifdef DEBUG_ENABLED
345345
if ((size_t)p_argcount > sizeof...(P)) {
346346
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
347-
r_error.argument = sizeof...(P);
347+
r_error.argument = (int32_t)sizeof...(P);
348348
return;
349349
}
350350
#endif
351351

352352
int32_t missing = (int32_t)sizeof...(P) - (int32_t)p_argcount;
353353

354-
int32_t dvs = default_values.size();
354+
int32_t dvs = (int32_t)default_values.size();
355355
#ifdef DEBUG_ENABLED
356356
if (missing > dvs) {
357357
r_error.error = GDNATIVE_CALL_ERROR_TOO_FEW_ARGUMENTS;
358-
r_error.argument = sizeof...(P);
358+
r_error.argument = (int32_t)sizeof...(P);
359359
return;
360360
}
361361
#endif

include/godot_cpp/core/math.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ inline double sinc(double p_x) {
163163
}
164164

165165
inline float sincn(float p_x) {
166-
return sinc(Math_PI * p_x);
166+
return (float)sinc(Math_PI * p_x);
167167
}
168168
inline double sincn(double p_x) {
169169
return sinc(Math_PI * p_x);

include/godot_cpp/core/method_bind.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ class MethodBind {
7171
public:
7272
const char *get_name() const;
7373
void set_name(const char *p_name);
74-
_FORCE_INLINE_ int get_default_argument_count() const { return default_arguments.size(); }
74+
_FORCE_INLINE_ int get_default_argument_count() const { return (int)default_arguments.size(); }
7575
_FORCE_INLINE_ const std::vector<Variant> &get_default_arguments() const { return default_arguments; }
7676
_FORCE_INLINE_ Variant has_default_argument(int p_arg) const {
77-
int idx = p_arg - (argument_count - default_arguments.size());
77+
int idx = p_arg - (argument_count - (int)default_arguments.size());
7878

7979
if (idx < 0 || idx >= default_arguments.size()) {
8080
return false;
@@ -83,7 +83,7 @@ class MethodBind {
8383
}
8484
}
8585
_FORCE_INLINE_ Variant get_default_argument(int p_arg) const {
86-
int idx = p_arg - (argument_count - default_arguments.size());
86+
int idx = p_arg - (argument_count - (int)default_arguments.size());
8787

8888
if (idx < 0 || idx >= default_arguments.size()) {
8989
return Variant();
@@ -159,7 +159,7 @@ class MethodBindVarArg : public MethodBind {
159159
}
160160

161161
void set_method_info(const MethodInfo &p_info, bool p_return_nil_is_variant) {
162-
set_argument_count(p_info.arguments.size());
162+
set_argument_count((int)p_info.arguments.size());
163163
if (p_info.arguments.size()) {
164164
std::vector<std::string> names;
165165
names.reserve(p_info.arguments.size());
@@ -175,7 +175,7 @@ class MethodBindVarArg : public MethodBind {
175175
if (p_return_nil_is_variant) {
176176
arguments.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
177177
}
178-
generate_argument_types(p_info.arguments.size());
178+
generate_argument_types((int)p_info.arguments.size());
179179
}
180180

181181
virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return) const {
@@ -252,7 +252,7 @@ class MethodBindT : public MethodBind {
252252

253253
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
254254
#ifdef TYPED_METHOD_BIND
255-
call_with_variant_args_dv(static_cast<T *>(p_instance), method, p_args, p_argument_count, r_error, get_default_arguments());
255+
call_with_variant_args_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, r_error, get_default_arguments());
256256
#else
257257
call_with_variant_args_dv(reinterpret_cast<MB_T *>(p_instance), method, p_args, p_argument_count, r_error, get_default_arguments());
258258
#endif
@@ -330,7 +330,7 @@ class MethodBindTC : public MethodBind {
330330

331331
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
332332
#ifdef TYPED_METHOD_BIND
333-
call_with_variant_argsc_dv(static_cast<T *>(p_instance), method, p_args, p_argument_count, r_error, get_default_arguments());
333+
call_with_variant_argsc_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, r_error, get_default_arguments());
334334
#else
335335
call_with_variant_argsc_dv(reinterpret_cast<MB_T *>(p_instance), method, p_args, p_argument_count, r_error, get_default_arguments());
336336
#endif
@@ -414,7 +414,7 @@ class MethodBindTR : public MethodBind {
414414
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
415415
Variant ret;
416416
#ifdef TYPED_METHOD_BIND
417-
call_with_variant_args_ret_dv(static_cast<T *>(p_instance), method, p_args, p_argument_count, ret, r_error, get_default_arguments());
417+
call_with_variant_args_ret_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, ret, r_error, get_default_arguments());
418418
#else
419419
call_with_variant_args_ret_dv((MB_T *)p_instance, method, p_args, p_argument_count, ret, r_error, get_default_arguments());
420420
#endif
@@ -499,7 +499,7 @@ class MethodBindTRC : public MethodBind {
499499
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
500500
Variant ret;
501501
#ifdef TYPED_METHOD_BIND
502-
call_with_variant_args_retc_dv(static_cast<T *>(p_instance), method, p_args, p_argument_count, ret, r_error, get_default_arguments());
502+
call_with_variant_args_retc_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, ret, r_error, get_default_arguments());
503503
#else
504504
call_with_variant_args_retc_dv((MB_T *)p_instance, method, p_args, p_argument_count, ret, r_error, get_default_arguments());
505505
#endif

include/godot_cpp/variant/aabb.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ inline void AABB::expand_to(const Vector3 &p_vector) {
336336
}
337337

338338
void AABB::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const {
339-
Vector3 half_extents(size.x * 0.5, size.y * 0.5, size.z * 0.5);
339+
Vector3 half_extents(size.x * (real_t)0.5, size.y * (real_t)0.5, size.z * (real_t)0.5);
340340
Vector3 center(position.x + half_extents.x, position.y + half_extents.y, position.z + half_extents.z);
341341

342342
real_t length = p_plane.normal.abs().dot(half_extents);
@@ -374,9 +374,9 @@ inline real_t AABB::get_shortest_axis_size() const {
374374
}
375375

376376
bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const {
377-
real_t divx = 1.0 / p_dir.x;
378-
real_t divy = 1.0 / p_dir.y;
379-
real_t divz = 1.0 / p_dir.z;
377+
real_t divx = (real_t)1.0 / p_dir.x;
378+
real_t divy = (real_t)1.0 / p_dir.y;
379+
real_t divz = (real_t)1.0 / p_dir.z;
380380

381381
Vector3 upbound = position + size;
382382
real_t tmin, tmax, tymin, tymax, tzmin, tzmax;
@@ -426,9 +426,9 @@ void AABB::grow_by(real_t p_amount) {
426426
position.x -= p_amount;
427427
position.y -= p_amount;
428428
position.z -= p_amount;
429-
size.x += 2.0 * p_amount;
430-
size.y += 2.0 * p_amount;
431-
size.z += 2.0 * p_amount;
429+
size.x += (real_t)2.0 * p_amount;
430+
size.y += (real_t)2.0 * p_amount;
431+
size.z += (real_t)2.0 * p_amount;
432432
}
433433

434434
void AABB::quantize(real_t p_unit) {

include/godot_cpp/variant/color.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class Color {
157157

158158
inline Color blend(const Color &p_over) const {
159159
Color res;
160-
float sa = 1.0 - p_over.a;
160+
float sa = (real_t)1.0 - p_over.a;
161161
res.a = a * sa + p_over.a;
162162
if (res.a == 0) {
163163
return Color(0, 0, 0, 0);
@@ -171,16 +171,16 @@ class Color {
171171

172172
inline Color to_linear() const {
173173
return Color(
174-
r < 0.04045 ? r * (1.0 / 12.92) : Math::pow((r + 0.055) * (1.0 / (1 + 0.055)), 2.4),
175-
g < 0.04045 ? g * (1.0 / 12.92) : Math::pow((g + 0.055) * (1.0 / (1 + 0.055)), 2.4),
176-
b < 0.04045 ? b * (1.0 / 12.92) : Math::pow((b + 0.055) * (1.0 / (1 + 0.055)), 2.4),
174+
r < (real_t)0.04045 ? r * (real_t)(1.0 / 12.92) : Math::pow((r + (real_t)0.055) * (real_t)(1.0 / (1.0 + 0.055)), (real_t)2.4),
175+
g < (real_t)0.04045 ? g * (real_t)(1.0 / 12.92) : Math::pow((g + (real_t)0.055) * (real_t)(1.0 / (1.0 + 0.055)), (real_t)2.4),
176+
b < (real_t)0.04045 ? b * (real_t)(1.0 / 12.92) : Math::pow((b + (real_t)0.055) * (real_t)(1.0 / (1.0 + 0.055)), (real_t)2.4),
177177
a);
178178
}
179179
inline Color to_srgb() const {
180180
return Color(
181-
r < 0.0031308 ? 12.92 * r : (1.0 + 0.055) * Math::pow(r, 1.0f / 2.4f) - 0.055,
182-
g < 0.0031308 ? 12.92 * g : (1.0 + 0.055) * Math::pow(g, 1.0f / 2.4f) - 0.055,
183-
b < 0.0031308 ? 12.92 * b : (1.0 + 0.055) * Math::pow(b, 1.0f / 2.4f) - 0.055, a);
181+
r < (real_t)0.0031308 ? (real_t)12.92 * r : (real_t)(1.0 + 0.055) * Math::pow(r, (real_t)(1.0 / 2.4)) - (real_t)0.055,
182+
g < (real_t)0.0031308 ? (real_t)12.92 * g : (real_t)(1.0 + 0.055) * Math::pow(g, (real_t)(1.0 / 2.4)) - (real_t)0.055,
183+
b < (real_t)0.0031308 ? (real_t)12.92 * b : (real_t)(1.0 + 0.055) * Math::pow(b, (real_t)(1.0 / 2.4)) - (real_t)0.055, a);
184184
}
185185

186186
static Color hex(uint32_t p_hex);
@@ -202,14 +202,14 @@ class Color {
202202
operator String() const;
203203

204204
// For the binder.
205-
inline void set_r8(int32_t r8) { r = (Math::clamp(r8, 0, 255) / 255.0); }
206-
inline int32_t get_r8() const { return int32_t(Math::clamp(r * 255.0, 0.0, 255.0)); }
207-
inline void set_g8(int32_t g8) { g = (Math::clamp(g8, 0, 255) / 255.0); }
208-
inline int32_t get_g8() const { return int32_t(Math::clamp(g * 255.0, 0.0, 255.0)); }
209-
inline void set_b8(int32_t b8) { b = (Math::clamp(b8, 0, 255) / 255.0); }
210-
inline int32_t get_b8() const { return int32_t(Math::clamp(b * 255.0, 0.0, 255.0)); }
211-
inline void set_a8(int32_t a8) { a = (Math::clamp(a8, 0, 255) / 255.0); }
212-
inline int32_t get_a8() const { return int32_t(Math::clamp(a * 255.0, 0.0, 255.0)); }
205+
inline void set_r8(int32_t r8) { r = (Math::clamp(r8, 0, 255) / (real_t)255.0); }
206+
inline int32_t get_r8() const { return int32_t(Math::clamp(r * (real_t)255.0, (real_t)0.0, (real_t)255.0)); }
207+
inline void set_g8(int32_t g8) { g = (Math::clamp(g8, 0, 255) / (real_t)255.0); }
208+
inline int32_t get_g8() const { return int32_t(Math::clamp(g * (real_t)255.0, (real_t)0.0, (real_t)255.0)); }
209+
inline void set_b8(int32_t b8) { b = (Math::clamp(b8, 0, 255) / (real_t)255.0); }
210+
inline int32_t get_b8() const { return int32_t(Math::clamp(b * (real_t)255.0, (real_t)0.0, (real_t)255.0)); }
211+
inline void set_a8(int32_t a8) { a = (Math::clamp(a8, 0, 255) / (real_t)255.0); }
212+
inline int32_t get_a8() const { return int32_t(Math::clamp(a * (real_t)255.0, (real_t)0.0, (real_t)255.0)); }
213213

214214
inline void set_h(float p_h) { set_hsv(p_h, get_s(), get_v()); }
215215
inline void set_s(float p_s) { set_hsv(get_h(), p_s, get_v()); }

include/godot_cpp/variant/quaternion.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,19 @@ class Quaternion {
152152
Vector3 c = v0.cross(v1);
153153
real_t d = v0.dot(v1);
154154

155-
if (d < -1.0 + CMP_EPSILON) {
156-
x = 0;
157-
y = 1;
158-
z = 0;
159-
w = 0;
155+
if (d < (real_t)-1.0 + CMP_EPSILON) {
156+
x = (real_t)0.0;
157+
y = (real_t)1.0;
158+
z = (real_t)0.0;
159+
w = (real_t)0.0;
160160
} else {
161-
real_t s = Math::sqrt((1.0 + d) * 2.0);
162-
real_t rs = 1.0 / s;
161+
real_t s = Math::sqrt(((real_t)1.0 + d) * (real_t)2.0);
162+
real_t rs = (real_t)1.0 / s;
163163

164164
x = c.x * rs;
165165
y = c.y * rs;
166166
z = c.z * rs;
167-
w = s * 0.5;
167+
w = s * (real_t)0.5;
168168
}
169169
}
170170
};
@@ -199,7 +199,7 @@ void Quaternion::operator*=(const real_t &s) {
199199
}
200200

201201
void Quaternion::operator/=(const real_t &s) {
202-
*this *= 1.0 / s;
202+
*this *= (real_t)1.0 / s;
203203
}
204204

205205
Quaternion Quaternion::operator+(const Quaternion &q2) const {
@@ -222,7 +222,7 @@ Quaternion Quaternion::operator*(const real_t &s) const {
222222
}
223223

224224
Quaternion Quaternion::operator/(const real_t &s) const {
225-
return *this * (1.0 / s);
225+
return *this * ((real_t)1.0 / s);
226226
}
227227

228228
bool Quaternion::operator==(const Quaternion &p_quat) const {

include/godot_cpp/variant/rect2.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
namespace godot {
3939

40-
struct Transform2D;
40+
class Transform2D;
4141

4242
class Rect2 {
4343
public:
@@ -290,7 +290,7 @@ class Rect2 {
290290

291291
//check ray box
292292
r /= l;
293-
Vector2 ir(1.0 / r.x, 1.0 / r.y);
293+
Vector2 ir((real_t)1.0 / r.x, (real_t)1.0 / r.y);
294294

295295
// lb is the corner of AABB with minimal coordinates - left bottom, rt is maximal corner
296296
// r.org is origin of ray

include/godot_cpp/variant/vector2.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,19 @@ inline Vector2 Vector2::plane_project(real_t p_d, const Vector2 &p_vec) const {
164164
}
165165

166166
inline Vector2 operator*(float p_scalar, const Vector2 &p_vec) {
167-
return p_vec * p_scalar;
167+
return p_vec * (real_t)p_scalar;
168168
}
169169

170170
inline Vector2 operator*(double p_scalar, const Vector2 &p_vec) {
171-
return p_vec * p_scalar;
171+
return p_vec * (real_t)p_scalar;
172172
}
173173

174174
inline Vector2 operator*(int32_t p_scalar, const Vector2 &p_vec) {
175-
return p_vec * p_scalar;
175+
return p_vec * (real_t)p_scalar;
176176
}
177177

178178
inline Vector2 operator*(int64_t p_scalar, const Vector2 &p_vec) {
179-
return p_vec * p_scalar;
179+
return p_vec * (real_t)p_scalar;
180180
}
181181

182182
inline Vector2 Vector2::operator+(const Vector2 &p_v) const {

0 commit comments

Comments
 (0)