We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The below program will output 0.000000 for all 6 values.
0.000000
#include <stdio.h> typedef struct xy { double x, y; } t_xy; t_xy vec(double x, double y) { return ( (t_xy){x, y} ); } t_xy operator+ (t_xy &a, t_xy &b) { return ( (t_xy){a.x + b.x, a.y + b.y} ); } int main(int argc, char *argv[]) { t_xy a = vec(1, 2); t_xy b = vec(2, 4); t_xy c = a + b; printf("a == %f %f\n", a.x, a.y); printf("b == %f %f\n", b.x, b.y); printf("c == %f %f\n", c.x, c.y); }
The same applies even to the simplest case:
t_xy test = (t_xy){1.0, 2.0}; printf("test == %f %f\n", test.x, test.y);
The text was updated successfully, but these errors were encountered:
Additionally, the following will not work (all zeroes on out):
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); }
Sorry, something went wrong.
LCC is a C89 compiler. It doesn't support compound literals, which were introduced with C99.
No branches or pull requests
The below program will output
0.000000
for all 6 values.The same applies even to the simplest case:
The text was updated successfully, but these errors were encountered: