【发布时间】:2010-04-05 03:46:47
【问题描述】:
我想用下一个结构写程序
stdafx.h - 包含一些程序常量的#define 定义和所有项目中使用的标头的#include。
frmMain.h - 包含 Form1 的代码也可以显示 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'
【问题讨论】:
-
您使用了“链接”标签;您遇到编译器错误还是链接器错误?
-
如果您将它们展示给我们,我们可能会提供帮助。
-
似乎没有正确包含标题。您是否有机会为每个文件使用相同的 MYMODULE_H ?
-
在您的
.cpp文件中,您是否曾在stdafx.h之前包含BckHeadr.h? -
对于所有文件,我有不同的 MYMODULE_H。我在 .cpp 文件中没有代码,所有代码都写在 .h 文件中。但我有 thr frmIniPrgs.cpp,其中写道:#include "stdafx.h" #include "frmIniPrgs.h"
标签: c++ visual-c++ linker header