问题#ifndef和#pragma一次

时间:2010-04-05 03:46:47

标签: c++ visual-c++ linker header

我想用下一个struct

编写程序

stdafx.h - 包含程序常量的#define defenition和所有项目中使用的#include of headers。

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。我喜欢这样:

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

我的项目中有下一个错误(我有俄语视觉工作室,错误文本是谷歌翻译翻译,可能包含错误,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' 

2 个答案:

答案 0 :(得分:1)

尝试

#include <vector>
using namespace std;

这可能会解决一些错误(如果不是全部)。

答案 1 :(得分:1)

您必须包含正确的STL标头。

#include <vector>

您还可以将名称空间添加为

using namespace std;

或者使用STL类作为

std::vector<>
相关问题