2011-09-08 95 views
-3

如何避免以下錯誤: -錯誤:之前預期基本表達式 「__attribute__」

error: expected primary-expression before "__attribute__" 

代碼:

#define A(name) __attribute__(name) 

如果我用我的代碼,該宏爲A(名稱),我收到錯誤的expected primary-expression before "__attribute__"

+0

你會談論html屬性,或者是什麼? – reporter

+0

for linker attributes – Akash

+0

發佈更多代碼。 –

回答

0

嘗試:

#define A(name) __attribute__((name))

由於沒有代碼,我不能說你是否正確使用它。

+0

其mot工作。這是我的代碼。 – Akash

+0

你做錯了。 __attribute__爲結構或函數提供了一個屬性。例如,您可以使用'void my_func()__attribute __((noreturn))'。 'printf(「%s」,__attribute((noreturn)));''絕對*無*感。 – wormsparty

+0

如果你真的想在printf中打印,試試:'#define A(name)「__attribute __((」name「))」' – wormsparty

相關問題