今天代码评审看到使用宏来初始化结构体的操作。
代码大致如下,你们觉得如何呢?
#include <stdio.h>
#define CAR(weight, width, height) { weight, width, height }
typedef struct Car
{
int weight;
int width;
int height;
} Car;
int main(int, char **)
{
Car car = CAR(100, 20, 10);
return 0;
}