[ create a new paste ] login | about

Link: http://codepad.org/0c1aUBLm    [ raw code | output | fork ]

C, pasted on Apr 14:
#include <stdio.h>

typedef struct {
    int a;
    int b;
} S;

#define F(a,b) ( v.a = a, v.b = b, v )

int main(void) {
    S s, v;

    s = ( v.a = 1, v.b = 2, v ); // this works as expected

    printf("s = { %d %d } \n", s.a, s.b);

    s = F(1, 2); // but gcc complains about the macro equivalent

    printf("s = { %d %d } \n", s.a, s.b);

    return 0;
}


Output:
1
2
In function 'main':
Line 17: error: expected identifier before numeric constant


Create a new paste based on this one


Comments: