c++ - "Cross-compatible" code spits errors in linux and compiles fine on windows! (GLM) -
i'm surprised, today downloaded ubuntu 12 lts 32bit , installed build essential.
then created makefile project copy pasted project internet , edited bit enable c++11 stuff if it's needed glm stuff?
anyway makefile:
gpp = g++ gcc = gcc plugin_outfile = "./quaternionstuff.so" compile_flags = -std=c++0x -m32 -o3 -fpic -c -i ./ -w -d linux -d project_name=\"plugin\" plugin = -d plugin $(compile_flags) all: plugin clean: -rm -f *~ *.o *.so plugin: clean $(gpp) $(plugin) ./*.cpp $(gpp) -std=c++0x -m32 --static -fshort-wchar -shared -o $(plugin_outfile) *.o now, when run it, linux spits there errors out , don't understand them..
now, code works on windows, compiles fine highest warning level etc, , it's good!
but g++ program not happy this:
no matching function call ‘getpitchyawbetweencoords(glm::vec3, glm::vec3, glm::vec2&)’ note: glm::vec2 getpitchyawbetweencoords(glm::vec3&, glm::vec3&) note: candidate expects 2 arguments, 3 provided //prototypes: inline glm::vec2 getpitchyawbetweencoords(glm::vec3 &source, glm::vec3 &target); inline void getpitchyawbetweencoords(glm::vec3 &source, glm::vec3 &target, glm::vec2 &output); and code, according functions calls it:
//the call inline void amxsetvector3(amx * amx, cell * ¶ms, unsigned char startpos, glm::vec3 vector) { //some code here } inline void amxsetvector2inverse(amx * amx, cell * ¶ms, unsigned char startpos, glm::vec2 vector) { //some code here } static cell amx_native_call getpitchyawbetweenpositions( amx* amx, cell* params ) { glm::vec2 rot; getpitchyawbetweencoords(amxgetvector3(params,1),amxgetvector3(params,4),rot); amxsetvector2inverse(amx,params,7,rot); return 1; } how hell can not distinguishsuch 2 very different functions (prototypes)? confusing part of errors, there more :(
i don't see wrong that.
so, is: change (with big pain, because code gets quircky because need change linux distirbution) functions different names, added 'r' end of second prototype, ton of errors come up..
in function ‘cell somefunction(amx*, cell*)’: error: invalid initialization of non-const reference of type ‘glm::vec3& {aka glm::detail::tvec3<float>&}’ rvalue of type ‘glm::detail::tvec3<float>’ and that's again.. on same function...:
static cell amx_native_call getpitchyawbetweenpositions( amx* amx, cell* params ) { glm::vec2 rot; getpitchyawbetweencoords(amxgetvector3(params,1),amxgetvector3(params,4),rot); amxsetvector2inverse(amx,params,7,rot);//here return 1; } what going on? have no idea how fix this..
the g++ version 4.6
apparently, amxgetvector3 returns glm::detail::tvec3<float>.
according standard, temporary object can't bound non-const reference (this second message trying tell you).
unfortunately, visual c++ has silly non-standard extension, enabled default, allows kind of binding.
change functions have these (const-correct) prototypes:
inline glm::vec2 getpitchyawbetweencoords(const glm::vec3 &source, const glm::vec3 &target); inline void getpitchyawbetweencoords(const glm::vec3 &source, const glm::vec3 &target, glm::vec2 &output);
Comments
Post a Comment