#define MAX_THREADS ( 17 )
struct thread_info
{
unsigned int * thread_sp; /* Storage space for thread stack-pointer. */
int thread_id; /* Storage space for a thread ID. */
};
struct thread_info thread_info_array[ MAX_THREADS ];我不明白第二个结构,你能解释一下它是做什么的吗?如果我们改变常量,常量是如何改变结构的?
更新
我认为这是一样的:
struct thread_info { unsigned int *thread_sp; int thread_id; } thread_info_array[MAX_THREADS];发布于 2013-03-23 18:12:02
它不是“第二个结构”。
这一点:
struct thread_info
{
unsigned int * thread_sp; /* Storage space for thread stack-pointer. */
int thread_id; /* Storage space for a thread ID. */
};是一个类型定义。
这一点:
struct thread_info thread_info_array[ MAX_THREADS ];是MAX_THREADS元素的数组定义,其中每个元素都是上面定义的struct thread_info类型。
发布于 2013-03-23 18:10:39
以下是
struct thread_info thread_info_array[ MAX_THREADS ];是先前声明的thread_info结构的数组。数组由MAX_THREADS元素组成;如果更改常量,则数组的大小也会更改。
有关需要第二个struct关键字的原因,请参阅C FAQ。
发布于 2013-03-23 18:10:59
struct thread_info thread_info_array[ MAX_THREADS ];意味着thread_info_array是MAX_THREADS元素的thread_info结构的数组。
更改常量只会更改数组中元素的数量,但不会影响struct定义。
https://stackoverflow.com/questions/15585514
复制相似问题