歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

uclinux-2008R1-RC8(bf561)到VDSP5的移植(13):未命名union的問題

在include/linux/shed.h中定義了一個結構體:

/*
* NOTE! "signal_struct" does not have it's own
* locking, because a shared signal_struct always
* implies a shared sighand_struct, so locking
* sighand_struct is always a proper superset of
* the locking of signal_struct.
*/
struct signal_struct {

/* job control IDs */
pid_t pgrp;
struct pid *tty_old_pgrp;

union {
pid_t session __deprecated;
pid_t __session;
};

};

在include/linux/init_task.h中定義了一個宏來對這個結構體進行初始化:

#define INIT_SIGNALS(sig) {                        /
.count = ATOMIC_INIT(1), /
.wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),/
.shared_pending = { /
.list = LIST_HEAD_INIT(sig.shared_pending.list), /
.signal = {{0}}}, /
.posix_timers = LIST_HEAD_INIT(sig.posix_timers), /
.cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), /
.rlim = INIT_RLIMITS, /
.pgrp = 0, /
.tty_old_pgrp = NULL, /
{ .__session = 0}, /
}

在這裡

{ .__session      = 0},  /

會引發一個錯誤:

"../../arch/blackfin/kernel/init_task.c", line 38: cc0136: error: union
"<unnamed>" has no field "__session"
static struct signal_struct init_signals = INIT_SIGNALS(init_signals);

怎麼看都有__session這個成員啊,實際引發這個錯誤的原因是在結構體中使用了未命名的union。因此必須做如下修改:

struct signal_struct {

/* job control IDs */
pid_t pgrp;
struct pid *tty_old_pgrp;

union {
pid_t session __deprecated;
pid_t __session;
}signal_struct_session;

};

其實就是隨便給這個union定義一個變量。

Copyright © Linux教程網 All Rights Reserved