Open Gontjarow opened 4 years ago
Additionally, the following will not work (all zeroes on out
):
t_xyz overloaded vec(double x, double y, double z)
{
printf("calling vec3 (in: %f %f %f)\n", x, y, z);
t_xyz out = {x, y, z};
printf("calling vec3 (out: %f %f %f)\n\n", out.x, out.y, out.z);
return (out);
}
But the following will work:
t_xyz overloaded vec(double x, double y, double z)
{
printf("calling vec3 (in: %f %f %f)\n", x, y, z);
t_xyz out;
out.x = x;
out.y = y;
out.z = z;
printf("calling vec3 (out: %f %f %f)\n\n", out.x, out.y, out.z);
return (out);
}
LCC is a C89 compiler. It doesn't support compound literals, which were introduced with C99.
The below program will output
0.000000
for all 6 values.The same applies even to the simplest case: