本文共 1629 字,大约阅读时间需要 5 分钟。
写个vc 6 中的控制台程序,出现一些错误,及解决过程。
如下顺序引用头文件
#include "gzip.h"
#include <io.h>//_finddata_t, _findfirst(), _findnext(), _findclose()
#include <stdlib.h>//_MAX_PATH, system() #include "stdafx.h" #include <stdio.h>程序中调用
::::DeleteFile(dFileName);
出现错误,DeleteFile is not a member of global namespace。
加上#include <windows.h>就不出错了
但是出现下面错误
--------------------Configuration: gzipdemo - Win32 Debug--------------------
Compiling... gzipdemo.cpp _Adding zlib library e:/program files/microsoft visual studio/vc98/include/winnt.h(195) : error C2143: syntax error : missing ';' before '*' e:/program files/microsoft visual studio/vc98/include/winnt.h(195) : error C2040: 'TCHAR' : 'char *' differs in levels of indirection from 'char' e:/program files/microsoft visual studio/vc98/include/winnt.h(195) : error C2059: syntax error : ';' e:/program files/microsoft visual studio/vc98/include/winnt.h(196) : error C2143: syntax error : missing ';' before '*' e:/program files/microsoft visual studio/vc98/include/winnt.h(196) : error C2373: 'TCHAR' : redefinition; different type modifiers e:/program files/microsoft visual studio/vc98/include/tchar.h(640) : see declaration of 'TCHAR' e:/program files/microsoft visual studio/vc98/include/winnt.h(196) : error C2059: syntax error : ';' Error executing cl.exe. gzipdemo.exe - 6 error(s), 0 warning(s)都是系统自带文件,怎么会出误呢。
终于发现个办法,把#include "gzip.h"放到最后,也即写成
如下顺序引用头文件
#include <io.h>//_finddata_t, _findfirst(), _findnext(), _findclose()
#include <stdlib.h>//_MAX_PATH, system() #include "stdafx.h" #include <stdio.h>#include "gzip.h"
蛮奇怪的
更奇怪的是编译通过一次后,再把#include "gzip.h"放回原处,也即又放到stdio.h等之前,也不报错了。
转载地址:http://taqbi.baihongyu.com/