2013-04-05 33 views
0

我工作的定義是這樣全局的一個項目:用Eclipse中的不同定義替換宏?

// Define an correctly-sized array of pointers to avoid static initialization. 
// Use an array of pointers instead of an array of char in case there is some alignment issue. 
#define DEFINE_GLOBAL(type, name, ...) \ 
    void * name[(sizeof(type) + sizeof(void *) - 1)/sizeof(void *)]; 

這顯然能正常工作,但會導致Eclipse來顯示這些全局變量爲錯誤之一的每一個使用。

,我寧願它是這樣的:

#define DEFINE_GLOBAL(type, name, ...) \ 
    type name; 

但我不能改變這個文件,那麼,有沒有辦法告訴Eclipse來假裝這是宏的定義是什麼?

回答

1

如果您#define是初始(不需要)定義之後的首選定義,那麼Eclipse在進行動態宏擴展時似乎使用最新的定義。

因此,如果您在您正在編輯的文件中重新編號爲#define,這可能會解決您的問題。

當然,這是一個kludge,可能會導致無法預料的問題,它可能會爲您的實施工作。