Question

I really don't understand why I get this error.

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’

This is my code :

    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);
    }

This is my second function :

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);
}

And this is my header:

#ifndef _STRUCT_H_
#define _STRUCT_H_

typedef struct s_result
{
    int   result1;
    int   result2;
}   t_result;

#endif /*  _STRUCT_H_ */

Also, I have some problem with cos and sin (and I didn't forget my include).

Was it helpful?

Solution

EDITED: @Hans is pointing out the basic problem, that you're defining my_rotation while trying to invoke my_rota. You shall fix this first.


Seems caused by implicit function declarations. Have you declared the function my_rotation before line 95?

You could try adding this line to your header:

extern t_result my_rotation(int x, int y, int degree);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top