L
Laurent Deniau
I was wondering if there is any good reason (semantic) to assume that
the following three code do not have the same efficiency (both space
and time):
struct A { int a,b,c; }; // could other types than int and with less/
more fields.
void g(struct A*);
// 1st case, C99
void f(int a, int b, int c) {
g(&(struct A*){ a,b,c }); // compound litteral
}
// 2nd case, C99
void f(int a, int b, int c) {
struct A a = { a,b,c }; // non-constant struct initializer
g(&a);
}
// 3rd case, C89
void f(int a, int b, int c) {
struct A a;
= { a,b,c }; // non-constant struct initializer
g(&a);
}
the following three code do not have the same efficiency (both space
and time):
struct A { int a,b,c; }; // could other types than int and with less/
more fields.
void g(struct A*);
// 1st case, C99
void f(int a, int b, int c) {
g(&(struct A*){ a,b,c }); // compound litteral
}
// 2nd case, C99
void f(int a, int b, int c) {
struct A a = { a,b,c }; // non-constant struct initializer
g(&a);
}
// 3rd case, C89
void f(int a, int b, int c) {
struct A a;
= { a,b,c }; // non-constant struct initializer
g(&a);
}