2010-04-05 50 views
1

我想接下來的結構問題的的#ifndef和#pragma一次

stdafx.h中寫程序 - 包含程序常量和頭的#include部分的#define defenitions至極使用中的所有項目。

frmMain.h - Form1的contatins代碼也可以顯示form2並使用BckHeadr.h中的一些代碼,一些函數調用stdafx.h中包含的頭文件。

frmIniPrgs.h - 包含Form2的代碼並使用BckHeadr.h中的一些代碼,並且某些函數調用stdafx.h中包含的頭文件。

BckHeadr.h - 包含函數的一些定義,一些函數調用stdafx.h中包含的頭文件。

我知道我必須使用#ifndef或#pragma once指令。但我不能決定這個問題。我包含在stdafx.h中:frmIniPrgs.H,BckHeadr.h,frmMain.h。並在所有模塊中使用#ifndef。我USET這樣的:

#ifndef MYMODULE_H 
#define MYMODULE_H 
//module code 
#endif 

有在我的項目旁邊的錯誤(我有俄羅斯的Visual Studio和錯誤的文本是由谷歌翻譯翻譯並可能包含錯誤,ScnIniPackages是我在BckHeadr.h功能) :

BckHeadr.h (96): error C3861: PtrToStringChars: identifier not found 
BckHeadr.h (141): error C2065: vector: undeclared identifier 
BckHeadr.h (141): error C2062: type "int" is not required 
BckHeadr.h (141): error C2143: syntax error: no ";" before "(" 
BckHeadr.h (141): error C2447: (: missing function header (possibly using a formal list of old type) 
BckHeadr.h (169): error C2065: vector: undeclared identifier 
frmIniPrgs.h (119): error C2065: vector: undeclared identifier 
frmIniPrgs.h (122): error C3861: ScnIniPackages: identifier not found 
frmIniPrgs.h (121): error C2065: vector: undeclared identifier 
C: \ Program Files \ Microsoft SDKs \ Windows \ v6.0A \ include \ Wininet.h (381): error C2872: FILETIME: ambiguous symbol 
    be 'C: \ Program Files \ Microsoft SDKs \ Windows \ v6.0A \ include \ windef.h (377): _FILETIME FILETIME' 
    or 'c: \ windows \ microsoft.net \ framework \ v2.0.50727 \ mscorlib.dll: System:: Runtime:: InteropServices:: FILETIME' 
+1

您使用的 「連接」 標籤;你遇到編譯器錯誤或鏈接器錯誤? – 2010-04-05 03:48:58

+0

我有很多編譯器錯誤 – Xaver 2010-04-05 04:01:11

+2

如果你向我們展示了它們,我們可能會幫助你。 – GManNickG 2010-04-05 04:03:13

回答

1

嘗試

#include <vector> 
using namespace std; 

這樣可以解決一些錯誤(如果不是全部)。

1

您必須包含正確的STL標頭。

#include <vector> 

你也可以添加一個命名空間

using namespace std; 

或者使用STL類爲

std::vector<>