使用include指令初始化聚合

前端之家收集整理的这篇文章主要介绍了使用include指令初始化聚合前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
很快的问题.我要复制&使用include指令将文本数据粘贴到单独文件的源代码中.

这合法吗?

struct Record; // collection of data fields

Record rec = { #include "some_big_record.txt" };

int numbers[] = { #include "some_long_sequence_of_numbers.txt" };

它适用于我的盒子(GCC),但它是否可移植?

解决方法

这是便携的:

Record rec = { 
#include "some_big_record.txt" 
};

猜你在找的设计模式相关文章