【发布时间】:2012-07-17 11:19:17
【问题描述】:
我正在使用以下代码。
const int X_ORIGIN = 1233086;
const int Y_ORIGIN = -4728071;
const int Z_ORIGIN = 4085704;
const int xyzOrigin[NUM_DIMENSIONS] = {X_ORIGIN, Y_ORIGIN, Z_ORIGIN};
当我编译它时,GCC 给了我以下错误。
Transformations.h:16:1: 错误:初始化元素不是常量
这是什么意思?如何修复我的代码?
【问题讨论】:
-
为什么不创建一个包含三个位置的结构,而不是一个数组?好像有点反直觉……
-
对@nathanwhite 所说的推论,John Carmack 说:twitter.com/ID_AA_Carmack/status/219884864185446402
标签: c constants initializer