Comments (3)
Hi Ettore,
You're right.
We have SIMD specializations of some common Vectors (such as
Vector<float,3>). Those SIMD specializations are in separate files,
however. It's possible to use the non-specialized Vectors before #including
the SIMD specialization files, unfortunately. That's the error you're
seeing.
I've refactored the headers so that the specializations are included with,
#include <mathfu/vector.h>
We'll push that change in the next point release, but for now you can work
around your compile error by including the specialization directly. That
is, use this instead:
#include <mathfu/vector_3.h>
Thanks for pointing this out!
Jason
On Wed, Aug 10, 2016 at 11:35 AM, Ettore Torti [email protected]
wrote:
If you include quaternion.h after including vector.h and instantiating a
Vector<float, 3>, you get template errors.Here's a small example to illustrate this happening.
myheader.h
#pragma once
#include <mathfu/vector.h>
struct MyStruct {
mathfu::Vector<float, 3> myVec;
};main.cpp
#include "myheader.h"
#include <mathfu/quaternion.h>int main() {
return 0;
}Trying to compile main.cpp with g++ will result in these errors:
$ g++ -I./include main.cpp
In file included from ./include/mathfu/matrix.h:22:0,
from ./include/mathfu/quaternion.h:25,
from main.cpp:2:
./include/mathfu/vector_3.h:66:7: error: specialization of ‘mathfu::Vector<float, 3>’ after instantiation
class Vector<float, 3> {
^
./include/mathfu/vector_3.h:66:7: error: redefinition of ‘class mathfu::Vector<float, 3>’
In file included from myheader.h:3:0,
from main.cpp:1:
./include/mathfu/vector.h:151:7: error: previous definition of ‘class mathfu::Vector<float, 3>’
class Vector {
^
./include/mathfu/vector.h: In constructor ‘mathfu::Vector<float, 4>::Vector(const mathfu::Vector<float, 3>&, const float&)’:
./include/mathfu/vector.h:679:12: error: ‘float mathfu::Vector<float, 3>::data_ [3]’ is private
T data_[d];
^
In file included from ./include/mathfu/matrix.h:23:0,
from ./include/mathfu/quaternion.h:25,
from main.cpp:2:
./include/mathfu/vector_4.h:73:26: error: within this context
data_.simd = vector3.data_.simd;
^
./include/mathfu/vector_4.h:73:32: error: request for member ‘simd’ in ‘vector3.mathfu::Vector<float, 3>::data_’, which is of non-class type ‘const float [3]’
data_.simd = vector3.data_.simd;—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#18, or mute the thread
https://github.com/notifications/unsubscribe-auth/AF3McGfTrMyPMXT4afx0tJJj_GPJF88Dks5qehnXgaJpZM4JhcXR
.
from mathfu.
Actually, we just pushed to github, so if you grab the latest, your code
should work now.
FYI, here's the fix:
7a5a6ef
On Wed, Aug 10, 2016 at 6:03 PM, Jason Sanmiya [email protected] wrote:
Hi Ettore,
You're right.
We have SIMD specializations of some common Vectors (such as
Vector<float,3>). Those SIMD specializations are in separate files,
however. It's possible to use the non-specialized Vectors before #including
the SIMD specialization files, unfortunately. That's the error you're
seeing.I've refactored the headers so that the specializations are included with,
#include <mathfu/vector.h>We'll push that change in the next point release, but for now you can work
around your compile error by including the specialization directly. That
is, use this instead:
#include <mathfu/vector_3.h>Thanks for pointing this out!
JasonOn Wed, Aug 10, 2016 at 11:35 AM, Ettore Torti [email protected]
wrote:If you include quaternion.h after including vector.h and instantiating a
Vector<float, 3>, you get template errors.Here's a small example to illustrate this happening.
myheader.h
#pragma once
#include <mathfu/vector.h>
struct MyStruct {
mathfu::Vector<float, 3> myVec;
};main.cpp
#include "myheader.h"
#include <mathfu/quaternion.h>int main() {
return 0;
}Trying to compile main.cpp with g++ will result in these errors:
$ g++ -I./include main.cpp
In file included from ./include/mathfu/matrix.h:22:0,
from ./include/mathfu/quaternion.h:25,
from main.cpp:2:
./include/mathfu/vector_3.h:66:7: error: specialization of ‘mathfu::Vector<float, 3>’ after instantiation
class Vector<float, 3> {
^
./include/mathfu/vector_3.h:66:7: error: redefinition of ‘class mathfu::Vector<float, 3>’
In file included from myheader.h:3:0,
from main.cpp:1:
./include/mathfu/vector.h:151:7: error: previous definition of ‘class mathfu::Vector<float, 3>’
class Vector {
^
./include/mathfu/vector.h: In constructor ‘mathfu::Vector<float, 4>::Vector(const mathfu::Vector<float, 3>&, const float&)’:
./include/mathfu/vector.h:679:12: error: ‘float mathfu::Vector<float, 3>::data_ [3]’ is private
T data_[d];
^
In file included from ./include/mathfu/matrix.h:23:0,
from ./include/mathfu/quaternion.h:25,
from main.cpp:2:
./include/mathfu/vector_4.h:73:26: error: within this context
data_.simd = vector3.data_.simd;
^
./include/mathfu/vector_4.h:73:32: error: request for member ‘simd’ in ‘vector3.mathfu::Vector<float, 3>::data_’, which is of non-class type ‘const float [3]’
data_.simd = vector3.data_.simd;—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#18, or mute the thread
https://github.com/notifications/unsubscribe-auth/AF3McGfTrMyPMXT4afx0tJJj_GPJF88Dks5qehnXgaJpZM4JhcXR
.
from mathfu.
Thanks for dealing with this so quickly :)
from mathfu.
Related Issues (20)
- Matrix vector product question.
- SIMD detection doesn't work on MSVC x64 targets HOT 5
- Projection function HOT 6
- Google_Mathfu failed with warning C4305 when build with MSVC HOT 3
- Expose GetColumn in Matrix
- Remove "vectorial" lib external dependency? HOT 2
- Support for double vectors/matrices (with SIMD)?
- matrix_4x4_simd.h is not included by default HOT 2
- Quaternions are 32 bytes due to alignment constraints instead of 16 bytes
- Api description in GLSL Mappings for typedef Matrix< float, 4, 4 > HOT 1
- CMAKE_SOURCE_DIR vs. CMAKE_CURRENT_SOURCE_DIR usage in studio 3.4 timeframe
- Google_MathFu failed to build due to error C1083 with MSVC on windows HOT 1
- Google_Mathfu failed with warning C4100 when build with MSVC
- When SIMD build disabled, Vector<T, Dims> miss some fundamental methods HOT 1
- Perspective projection matrix (what device coordinates is it mapping to?)
- Is this page wrong? I think there should be no parentheses. HOT 2
- method HadamardProduct of Matrix can not compile
- Bug on Quaternion::LookAt()
- Compile flag Not Updated HOT 1
- When building Google_MathFu emits warning C2220 on MSVC
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mathfu.