2
這是問題的設置:多個文件包含到一個單一的階級衝突
- MainFile.c調用文件SubFileA.h和SubFileB.h
- SubFileA.h需要調用類SigleClass.h
- SubFileB.h也需要調用類SingleClass.h
下面是該文件的內容。
MainFile.h包含以下行:
#include "SubFileA.h"
#include "SubFileB.h"
...
SubFileA.h包含以下行:
#include "SingleClass.h"
...
void InsertPendingRejectedTrx(SingleClass oLogic);
...
SubFileB.h包含以下行:
#include "SingleClass.h"
...
void InsertPendingRejectedTrx(SingleClass oAnotherLogic); //line 52
...
的SingleClass.h文件包含以下行:
#ifndef SC_LOGIC
#define SC_LOGIC
...
[lots of codes]
...
#endif
以下是錯誤代碼:
SubFileB.h: At global scope:
SubFileB.h:52: error: âSingleClassâ has not been declared
當我嘗試編譯時,編譯器返回一個錯誤。它說從SubFileB,「SingleClass」不包括在內。我怎麼解決這個問題?
注意:代碼已經在之前工作,但是當我由於某些原因從SubFileB.h中包含SingleClass時,編譯器返回了一個錯誤。
SubfileB.h是否包含SingleClass.h?還請添加哪個文件包含哪個標題的詳細信息。 – Raam
添加確切的錯誤信息。 – Kirill
Kirill,我添加了錯誤信息。 – ChinoCarloSedilla