const数组 [英] const array
问题描述
这是我的数据结构
typedef struct {
char colorType;
unsigned short numEntries;
unsigned int * palette;
} CLUT;
const unsigned int clut001palette [16] = {
0x8000F000 ,0x0000E000,0x0000C800,0x0000C000,
0x00009800,0x00009800,0x00009800,0x00048004,
0x00006C00,0x00006400,0x0008500C,0x00106810,
0x00108C10,0x00149814 ,0x0018A818,0x0018A018,
// ...
};
const CLUT clut001 = {RGBA555,256,clut001palette };
const CLUT clutList [] = {
clut001,
};
但是,它导致编译错误,任何希望我可以使用
变量来存储我的CLUT属性然后将它分配给一个数组?
非常感谢
here is my data structure
typedef struct{
char colorType;
unsigned short numEntries;
unsigned int* palette;
}CLUT;
const unsigned int clut001palette[16] = {
0x8000F000, 0x0000E000, 0x0000C800, 0x0000C000,
0x00009800, 0x00009800, 0x00009800, 0x00048004,
0x00006C00, 0x00006400, 0x0008500C, 0x00106810,
0x00108C10, 0x00149814, 0x0018A818, 0x0018A018,
//...
};
const CLUT clut001 = {RGBA555, 256, clut001palette};
const CLUT clutList[] = {
clut001,
};
however, it lead to an compile error, anyhope that I can use a
variable to store my CLUT attribute then assign it to an array?
thanks a lot
推荐答案
只是头脑风暴认为我可以这样编码
const CLUT * clutList [] = {
& clut001,& clut002
};
还有其他更好的办法吗?
On 7 30,3 4,jackymaill ... @ gmail.com写道:
just brainstorming think that I can code like this
const CLUT* clutList[] = {
&clut001, &clut002
};
Any other better approach?
On 7 30 , 3 44 , jackymaill...@gmail.com wrote:
这里是我的数据结构
typedef struct {
char colorType;
unsigned short numEntries;
unsigned int * palette;
} CLUT;
const unsigned int clut001palette [16] = {
0x8000F000,0x0000E000,0x0000C800,0x0000C000,
0x00009800,0x00009800,0x00009800,0x00048004,
0x00006C00,0x00006400,0x0008500C,0x00106810,
0x00108C10,0x00149814,0x0018A818,0x0018A018,
// ...
};
const CLUT clut001 = {RGBA555,256,clut001palette};
const CLUT clutList [] = {
clut001,
但是,它导致编译错误,任何希望我可以使用
变量来存储我的CLUT属性然后将它分配给一个数组?
非常感谢
here is my data structure
typedef struct{
char colorType;
unsigned short numEntries;
unsigned int* palette;
}CLUT;
const unsigned int clut001palette[16] = {
0x8000F000, 0x0000E000, 0x0000C800, 0x0000C000,
0x00009800, 0x00009800, 0x00009800, 0x00048004,
0x00006C00, 0x00006400, 0x0008500C, 0x00106810,
0x00108C10, 0x00149814, 0x0018A818, 0x0018A018,
//...
};
const CLUT clut001 = {RGBA555, 256, clut001palette};
const CLUT clutList[] = {
clut001,
};
however, it lead to an compile error, anyhope that I can use a
variable to store my CLUT attribute then assign it to an array?
thanks a lot
ja***********@gmail.com 写道:
ja***********@gmail.com wrote:
这里是我的数据结构
typedef struct {
char colorType;
unsigned short numEntries;
unsigned int * palette;
} CLUT;
const unsigned int clut001palette [16] = {
0x8000F000,0x0000E000,0x0000C800,0x0000C000,
0x00009800,0x00009800,0x00009800,0x00048004,
0x00006C00,0x00006400,0x0008500C,0x00106810,
0x00108C10,0x00149814,0x0018A818,0x0018A018,
// ...
};
const CLUT clut001 = {RGBA555,256,clut001palette};
const CLUT clutList [] = {
clut001,
但是,
然而,它会导致编译错误,无论如何我都是可以使用
变量来存储我的CLUT属性然后将其分配给数组?
here is my data structure
typedef struct{
char colorType;
unsigned short numEntries;
unsigned int* palette;
}CLUT;
const unsigned int clut001palette[16] = {
0x8000F000, 0x0000E000, 0x0000C800, 0x0000C000,
0x00009800, 0x00009800, 0x00009800, 0x00048004,
0x00006C00, 0x00006400, 0x0008500C, 0x00106810,
0x00108C10, 0x00149814, 0x0018A818, 0x0018A018,
//...
};
const CLUT clut001 = {RGBA555, 256, clut001palette};
const CLUT clutList[] = {
clut001,
};
however, it lead to an compile error, anyhope that I can use a
variable to store my CLUT attribute then assign it to an array?
什么是编译错误?
发布包含所有错误的完整,最小程序。
Brian
What is the compile error?
Post a complete, minimal program with all the errors.
Brian
它指向我的上一个数组
const CLUT clutList [] = {
clut001,
并说
初始化程序不是常数
7月30日,4月29日,默认用户 < defaultuse ... @ yahoo.comwrote:
It point to my last array
const CLUT clutList[] = {
clut001,
};
and said
"initializer is not a constant"
On 7 30 , 4 29 , "Default User" <defaultuse...@yahoo.comwrote:
jackymaill ... @ gmail.com写道:
jackymaill...@gmail.com wrote:
这里是我的数据结构
here is my data structure
typedef struct {
char colorType;
unsigned short numEntries;
unsigned int * palette;
} CLUT;
typedef struct{
char colorType;
unsigned short numEntries;
unsigned int* palette;
}CLUT;
const unsigned int clut001palette [16] = {
0x8000F000,0x0000E000,0x0000C800,0x0000C000,
0x00009800,0x00009800,0x00009800,0x00048004,
0x00006C00,0x00006400,0x0008500C,0x00106810,
0x00108C10,0x00149814,0x0018A818,0x0018A018,
// ...
};
const unsigned int clut001palette[16] = {
0x8000F000, 0x0000E000, 0x0000C800, 0x0000C000,
0x00009800, 0x00009800, 0x00009800, 0x00048004,
0x00006C00, 0x00006400, 0x0008500C, 0x00106810,
0x00108C10, 0x00149814, 0x0018A818, 0x0018A018,
//...
};
const CLUT clut001 = {RGBA555,256,clut001palette};
const CLUT clut001 = {RGBA555, 256, clut001palette};
const CLUT clutList [] = {
clut001,
};
const CLUT clutList[] = {
clut001,
};
然而,它会导致编译错误,无论如何我可以使用
变量来存储我的CLUT属性然后将它分配给一个数组?
however, it lead to an compile error, anyhope that I can use a
variable to store my CLUT attribute then assign it to an array?
什么是编译错误?
发布一个完整的,最小的程序,包含所有错误。
Brian
What is the compile error?
Post a complete, minimal program with all the errors.
Brian
这篇关于const数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!