I'm trying to compile my code from the old MS-DOS days and this doesn't seem to work with GCC:
typedef struct { int x,y,z; } vector;
inline void vect_add(vector& c,vector a, vector b)
{
c.x=a.x b.x;
c.y=a.y b.y;
c.z=a.z b.z;
}
Basically I'm trying to return a struct which is later used as vector.x etc instead of rewriting it as a pointer to struct and rewriting all as vector->x etc
see (vector& c,
CodePudding user response:
That is possibly valid C , but it's not valid C.
In C, you need to use a pointer, a global var, or actually return a struct.
typedef struct { int x, y, z; } vector;
inline void vect_add(vector* c, vector a, vector b)
{
c->x = a.x b.x;
c->y = a.y b.y;
c->z = a.z b.z;
}
vect_add(&c, a, b);