質問が他の場所で既に行われていることは知っていますが、ここで何が問題なのかわかりません。2 つの配列が構造内にあるため、何か間違っている可能性があります。
(編集:他のコードから構造を取得していますが、変更できません)
float の 2 つの配列を関数に渡してから、操作の結果を最初の配列に保存しようとしています。
core.h:
typedef struct{
//other stuff
float m_vector[16];
} structure_t;
class CoreClass{
private:
structure_t s1;
structure_t s2;
float *MyFunction(const float *vDest, const float *vNew);
}
コア.cpp:
#include "core.h"
#include "another_file.h"
void anotherFunction(){
//....
s1.m_vector = MyFunction(s1.m_vector, s2.m_vector); //error here
//....
}
float *CoreClass::MyFunction(const float *vDest, const float *vNew){
return yet_another_function(vDest, vNew);
}
ただし、関数を呼び出すと、次のエラーが発生します。
error: incompatible types in assignment of ‘float*’ to ‘float [16]’
完全を期すために、ここに私が呼び出している関数がありますが、コンパイル時に問題はないようです:
another_file.h
static __inline float *yet_another_function(const float *vDest, const float *vNew){
float *tmp = new float[16];
//tmp = matrix multiplication (vDest * vNew)
for(int i=0; i<4; i++)
for(int j = 0; j<4;j++)
for(int k = 0; 4; k++)
tmp[i + j*4] += vDest[i + k*4] * vNew[k + j*4];
return tmp;
}