當前位置:編程學習大全網 - 網站源碼 - 關於windows下C++程序移植到linux下的壹些頭文件對應問題

關於windows下C++程序移植到linux下的壹些頭文件對應問題

必須要封裝osa適配層了,兩者有些API有差異,靠單純的換頭文件搞不定。

比如妳想同時在linux和windows上使用stat這個函數,同樣是包含#include<sys/stat.h>,但是stat的結構體根本就不壹樣。

linux版本:

typedef?struct?stat

{

unsigned?long?st_dev;?/*?device?ID?number?*/

unsigned?long?st_ino;?/*?file?serial?number?*/

unsigned?short?st_mode;?/*?file?mode?(see?below)?*/

short?st_nlink;?/*?number?of?links?to?file?*/

short?st_uid;?/*?user?ID?of?file's?owner?*/

short?st_gid;?/*?group?ID?of?file's?group?*/

unsigned?long?st_rdev;?/*?device?ID,?only?if?special?file?*/

unsigned?long?st_size;?/*?size?of?file,?in?bytes?*/

unsigned?long?st_atime;?/*?time?of?last?access?*/

unsigned?long?st_mtime;?/*?time?of?last?modification?*/

unsigned?long?st_ctime;?/*?time?of?last?change?of?file?status?*/

long?st_blksize;

long?st_blocks;

unsigned?int?st_attrib;?/*?file?attribute?byte?(dosFs?only)?*/

}stat_type;

windows版本:

struct?stat?{

_dev_t?st_dev;

_ino_t?st_ino;

unsigned?short?st_mode;

short?st_nlink;

short?st_uid;

short?st_gid;

_dev_t?st_rdev;

_off_t?st_size;

time_t?st_atime;

time_t?st_mtime;

time_t?st_ctime;

};

  • 上一篇:如何把優惠券鏈接從PC改成手機?
  • 下一篇:用C語言解析JSON數據
  • copyright 2024編程學習大全網