Is it possible to create inline structures in C?
typedef struct {
int x;
int y;
} Point;
Point f(int x) {
Point retval = { .x = x, .y = x*x };
return retval;
}
Point g(int x) {
return { .x = x, .y = x*x };
}
freally gnot. The same applies to function calls:
float distance(Point a, Point b) {
return 0.0;
}
int main() {
distance({0, 0}, {1, 1})
}
Is it possible to create these structures without the need to use an additional temporary variable (which will be optimized by the compiler, I think, but an indicator of readability too)?
source
share