我在我的代碼如下聲明:變量聲明的問題
u32 volatile __attribute__((nocast)) *A, *B;
這是等同於:
u32 volatile __attribute__((nocast)) *A;
u32 volatile __attribute__((nocast)) *B;
或:
u32 volatile __attribute__((nocast)) *A;
u32 volatile *B;
甚至:
u32 volatile __attribute__((nocast)) *A;
u32 *B;
這是一個小的更新。這是linux內核代碼,所以唯一可能的編譯器是gcc。我知道我可能最終會寫多行,但我很好奇。
例如,在以下linux kernel code中,它們的用法與我想要的類似。這是代碼錯誤嗎?
最後一個更新,如果我用下面的代碼:
int main() {
int __attribute__((weak)) a, b;
}
我得到下GCC以下警告:
foo.c: In function ‘main’:
foo.c:5: error: weak declaration of ‘a’ must be public
foo.c:5: error: weak declaration of ‘b’ must be public
這是說,我認爲它試圖以應用屬性到兩個變量。我將運行它的想法,它不會改變屬性類型。
我不知道那是否意味着其他讀代碼的人可能不會。爲什麼不只是長時間打字並擺脫歧義。 – 2010-09-17 17:15:39
或使用typedef ... – 2010-09-17 17:18:30
@Paul R - 你可以在'typedef'中使用'__attribute__'嗎? – detly 2010-09-17 17:26:09