2013-08-16 52 views
0

請幫我理解gcc編譯器的輸出。我完全困惑。錯誤:聲明'<...>'。奇怪的編譯錯誤

我有一個錯誤:

C/types.h:47:56: error: declaration of 
'struct VV::MM<VV::SSS::Vector<short unsigned int>, 8u, 0u>' 

這已經有些陌生。

在types.h中:47我看到:

template<typename V, size_t Size1, size_t Size2> class MM; 

這是看起來不錯我。

這是構建日誌中的第二個錯誤消息,我不知道它可能只是第一個錯誤的第二部分?這裏第一和第二誤差在一起:

<... compiles normally, no errors ...> 

In file included from A/T.h:14:0, 
       from B/I.h:5, 
       from B/F.cxx:54: 
A/AArray.h: In instantiation of 
'AInternal::AlignedData<VV::MM<VV::SSS::Vector<short unsigned int>, 8u, 0u>, 104u, 0>': 
A/AArray.h:561:125: instantiated from 
'AFArray<VV::MM<VV::SSS::Vector<short unsigned int>, 8u, 0u>, AArraySize<104u> >' 
A/V.h:73:99: instantiated from here 
A/AArray.h:364:20: error: 'AInternal::AlignedData<T, Size, 0>::fArray' 
    has incomplete type 

C/types.h:47:56: error: declaration of 
'struct VV::MM<VV::SSS::Vector<short unsigned int>, 8u, 0u>' 

In file included from <...other errors...> 

在A/VH:73我有:

AFArray<VV::SSS::Vector<short unsigned int>::MM, AAArraySize<N> > fAlpha; 

,我相信可以觸發在日誌中第二行:

A/AArray.h: In instantiation of 
'AInternal::AlignedData<VV::MM<VV::SSS::Vector<short unsigned int>, 8u, 0u>, 104u, 0>': 

因爲由於第二個錯誤,VV :: SSS :: Vector :: MM是未定義的類型。

所以我有2個問題:

  1. 是第二個錯誤消息的第一個錯誤的一部分嗎?
  2. 這個聲明有什麼問題?
+0

將types.h中的所有環繞代碼行粘貼到您的問題中(具體來說,緊接在types.h的第47行左右的半打左右的行中,包括該行)。 – WhozCraig

+1

自上而下閱讀錯誤消息。分別修復它們中的每一個。在編譯器遇到錯誤後,它會嘗試儘可能恢復和繼續,但語言是上下文敏感的,並且可能無法正確恢復,因此需要用少許鹽來獲取第二個和更多錯誤消息。 –

+3

在gcc中,第一個錯誤塊從第一個'從文件包含的文件'到第二個'包含文件的文件'。在這個塊中,第一次出現'error:'或'warning:'是編譯器抱怨的地方。在它上面,你會發現爲什麼gcc甚至在看那個文件,它在做什麼(它正在編譯的函數,或者你的情況下是哪個模板被實例化),接下來是爲什麼它需要這樣做。在'error:'之下,根據具體情況可能會有所幫助。什麼函數定義是可用的('note:'),可能是爲什麼它們不適合('error:')。 – mars

回答

0

問題是我丟失了描述定義的MM類的文件。文件已找到並添加到包含錯誤消失的路徑。

回答我的問題:

Is the second error message a part of the first error?

是。它看起來如此。

What can be wrong with this declaration?

沒有錯,編譯器只是告訴與錯誤聲明有關。