首页 > Windows开发 > 详细

linux & windows porting

时间:2016-06-16 00:02:49      阅读:437      评论:0      收藏:0      [点我收藏+]


1. linux   int snprintf(char *restrict buf, size_t n, const char * restrict   format, ...);

   windows  int _snprintf(


2. 头文件都是string. h
 windows平台:函数:stricmp(char *str1, char *str2), strnicmp(char *str1, char *str2, size_t n).
Linux平台: 函数:strcasecmp(char *str1, char *str2), strncasecmp(char *str1, char *str2, size_t n).


3. linux环境下是:vsnprintf
    VC6环境下是:_vsnprintf
   AString.cpp  linux vasprintf()
    

  1. static int vasprintf(char **strp, const char *fmt, va_list va)  

  2. {  

  3.     const int required = vsnprintf(NULL, 0, fmt, va);  

  4.     char *const buffer = (char *) malloc(required + 1);  

  5.     const int ret = vsnprintf(buffer, required + 1, fmt, va);  

  6.     *strp = buffer;  

  7.     return ret;  

  8. }

   4. windows下winsock.h/winsock2.h
    linux下sys/socket.h    错误处理:errno.h


5. write windows头文件
  include unistd.h


6. socklen_t 
     windows 头文件 #include<ws2tcpip.h>
      linux   下头文件

      1)#include <sys/socket.h>
      2)#include <unistd.h>

linux & windows porting

原文:http://lindt.blog.51cto.com/9699125/1789667

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!