From 901c394bf8ecb1ab9c32430a4b08e6fc078ace5c Mon Sep 17 00:00:00 2001 From: kingscallop <54776947+kingscallop@users.noreply.github.com> Date: Sat, 30 Apr 2022 20:50:25 +0100 Subject: [PATCH 1/2] Fix could not convert template argument error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When compiling to a x86-64 target using gcc, clang and msvc the following error appears: In file included from spark/include/SPARK_Core.h:38, from spark/src/Core/IO/SPK_IO_Buffer.cpp:22: spark/include/Core/SPK_DescriptionDefines.h:266:123: error: could not convert template argument ‘&SPK::Group::getCapacity’ from ‘size_t (SPK::Group::*)() const’ {aka ‘long unsigned int (SPK::Group::*)() const’} to ‘unsigned int (SPK::Group::*)() const’ 266 | ::template store,\ | spark/include/Core/SPK_DescriptionDefines.h:154:25: note: in definition of macro ‘_spk_description_body’ 154 | __VA_ARGS__ \ | ^~~~~~~~~~~ spark/include/Core/SPK_Group.h:373:25: note: in expansion of macro ‘spk_attribute’ 373 | spk_attribute(unsigned int, capacity, reallocate, getCapacity); | ^~~~~~~~~~~~~ On a x86-64 target (using those compilers) the size of size_t is 64bit and the size of unsigned int is 32bit hence the 'could not convert' error. The ParticleData struct field nbParticles was also set to unsigned int fix the packing. --- include/Core/SPK_Group.h | 14 +++++++------- src/Core/SPK_Group.cpp | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/Core/SPK_Group.h b/include/Core/SPK_Group.h index 823562ed..8fdec7a6 100644 --- a/include/Core/SPK_Group.h +++ b/include/Core/SPK_Group.h @@ -91,13 +91,13 @@ namespace SPK bool isEnabled(Param param) const; - size_t getNbParticles() const; - size_t getCapacity() const; + unsigned int getNbParticles() const; + unsigned int getCapacity() const; Particle getParticle(size_t index); const Particle getParticle(size_t index) const; - void reallocate(size_t capacity); + void reallocate(unsigned int capacity); void empty(); void addEmitter(const Ref& emitter); @@ -401,8 +401,8 @@ namespace SPK { bool initialized; - size_t nbParticles; - size_t maxParticles; + unsigned int nbParticles; + unsigned int maxParticles; // Particles attributes Vector3D* positions; @@ -734,12 +734,12 @@ namespace SPK return particleData.parameters[param] != NULL; } - inline size_t Group::getNbParticles() const + inline unsigned int Group::getNbParticles() const { return particleData.nbParticles; } - inline size_t Group::getCapacity() const + inline unsigned int Group::getCapacity() const { return particleData.maxParticles; } diff --git a/src/Core/SPK_Group.cpp b/src/Core/SPK_Group.cpp index ed241df5..4a7cae98 100644 --- a/src/Core/SPK_Group.cpp +++ b/src/Core/SPK_Group.cpp @@ -54,7 +54,7 @@ namespace SPK deathAction(), octree(NULL) { - reallocate(capacity); + reallocate(static_cast(capacity)); } Group::Group(const Group& group) : @@ -270,7 +270,7 @@ namespace SPK } } - void Group::reallocate(size_t capacity) + void Group::reallocate(unsigned int capacity) { SPK_ASSERT(capacity != 0,"Group::reallocate(size_t) - Group capacity must not be 0"); From 020c176285b0ae2d104b752b98564e9c26042cac Mon Sep 17 00:00:00 2001 From: kingscallop <54776947+kingscallop@users.noreply.github.com> Date: Sat, 30 Apr 2022 20:54:45 +0100 Subject: [PATCH 2/2] Fix warnings on mingw64 about missing inline specifier --- include/Core/SPK_Group.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/Core/SPK_Group.h b/include/Core/SPK_Group.h index 8fdec7a6..5a6335ce 100644 --- a/include/Core/SPK_Group.h +++ b/include/Core/SPK_Group.h @@ -91,14 +91,14 @@ namespace SPK bool isEnabled(Param param) const; - unsigned int getNbParticles() const; - unsigned int getCapacity() const; + inline unsigned int getNbParticles() const; + inline unsigned int getCapacity() const; Particle getParticle(size_t index); const Particle getParticle(size_t index) const; void reallocate(unsigned int capacity); - void empty(); + inline void empty(); void addEmitter(const Ref& emitter); void removeEmitter(const Ref& emitter);