我真的不明白为什么会收到这个错误。
architect.c: In function ‘main’:
architect.c:91:20: error: incompatible types when assigning to type ‘t_result’ from type ‘int’
architect.c:93:20: error: incompatible types when assigning to type ‘t_result’ from type ‘int’
architect.c:95:20: error: incompatible types when assigning to type ‘t_result’ from type ‘int’
architect.c:97:20: error: incompatible types when assigning to type ‘t_result’ from type ‘int’
architect.c:99:20: error: incompatible types when assigning to type ‘t_result’ from type ‘int’
这是我的代码:
if (av[j][i] == 'R')
{
printf("rotation d'angle %s degrés\n", av[j + 1]);
if (av[j - 3][i] == 'T')
91 s_rota = my_rota(s_trans.result1, s_trans.result2, atoi(av[j + 1]));
else if (av[j - 3][i] == 'H')
93 s_rota = my_rota(s_homot.result1, s_homot.result2, atoi(av[j + 1]));
else if (av[j - 2][i] == 'S')
95 s_rota = my_rota(s_sym.result1, s_sym.result2, atoi(av[j + 1]));
else if (av[j - 2][i] == 'R')
97 s_rota = my_rota(s_rota.result1, s_rota.result2, atoi(av[j + 1]));
else
99 s_rota = my_rota(atoi(av[j - 2]), atoi(av[j - 1]), atoi(av [j + 1]));
printf("(%s,%s) => (%d,%d)\n", av[j - 2], av[j - 1], s_rota.result1, s_rota.result2);
}
这是我的第二个功能:
t_result my_rotation(int x, int y, int degree)
{
t_result s_rota;
s_rota.result1 = (cos(degree) * x) - (sin(degree) * y);
s_rota.result2 = (sin(degree) * x) + (cos(degree) * y);
return (s_rota);
}
这是我的标题:
#ifndef _STRUCT_H_
#define _STRUCT_H_
typedef struct s_result
{
int result1;
int result2;
} t_result;
#endif /* _STRUCT_H_ */
另外,我在cos
和sin
方面遇到了一些问题(我没有忘记我的内容)。
答案 0 :(得分:1)
已编辑:@Hans指出了基本问题,即您在尝试调用my_rotation
时定义了my_rota
。你应该先解决这个问题。
由implicit function declarations引起的似乎。你在第95行之前声明了函数my_rotation
吗?
您可以尝试将此行添加到标题中:
extern t_result my_rotation(int x, int y, int degree);