1 变量声明的位置
vc++6.0 不支持在代码中间声明变量。所以最好变量统一在函数的开始处统一进行声明。
2 inline 关键字
在vc++6.0下是__inline, 所以要修改工程属性,在project->[setting]->[c/c++]->Preprocessor definitions:编辑框里输入inline=__inline即可。
3fatal error C1010: unexpected end of file while looking for precompiled header directive
选中文件,右键设置-》c/c++-》分类中选择预统的头文件-》选中不使用预补偿页眉
4 休眠函数
linux下为sleep(n),休眠n秒;另外还提供一个微秒级函数usleep(n);
vc++为Sleep(n) ,休眠n毫秒,注意第一个字母为大写
5 系统节拍
long tv_sec;/*秒*/
long tv_usec;/*微妙*/
};
struct timezone{
int tz_minuteswest;/*和greenwich 时间差了多少分钟*/
int tz_dsttime;/*type of DST correction*/
};
6 错误代码
7 临界区
初始化:void WINAPI InitializeCriticalSection(_Out_ LPCRITICAL_SECTION lpCriticalSection);
进入临界区:void WINAPI EnterCriticalSection(_Inout_ LPCRITICAL_SECTION lpCriticalSection);
退出临界区:void WINAPI LeaveCriticalSection(_Inout_ LPCRITICAL_SECTION lpCriticalSection);
销毁临界区:void WINAPI DeleteCriticalSection(_Inout_ LPCRITICAL_SECTION lpCriticalSection);
linux:pthread_mutex_t
初始化:int pthread_mutex_init(pthread_mutex_t *restrict mutex,const pthread_mutexattr_t *restrict attr);
进入临界区:int pthread_mutex_lock(pthread_mutex_t *mutex);
退出临界区:int pthread_mutex_unlock(pthread_mutex_t *mutex);
销毁临界区:int pthread_mutex_destroy(pthread_mutex_t *mutex);
8 线程创建
9 事件
10 变参的宏定义
vc++下不支持变参的宏定义,故为了移植平台的方便,不要使用变参的宏定义