添加判断平台,编译器的助手函数

master
zcy 2020-08-29 23:30:19 +08:00
parent d2664d98e1
commit 4fe2c2638c
6 changed files with 50 additions and 1 deletions

7
general/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"files.associations": {
"cstring": "cpp",
"memory": "cpp"
}
}

View File

@ -7,7 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <string> #include <string>
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int dumpObj(void *dst,int rowNum,int num,bool ifAsii,char *out); int dumpObj(void *dst,int rowNum,int num,bool ifAsii,char *out);

View File

@ -12,6 +12,21 @@
using namespace std; using namespace std;
typedef enum {
ENV_WINDOWS = 1,
ENV_LINUX,
ENV_UNIX
}ENV_SYS;
typedef enum{
GCC = 1,
CLANG = 2,
CL = 3
}ENV_COMPILER;
inline ENV_SYS CurrentEnvSys();
inline ENV_COMPILER CurrentEnvCompiler();
#define RELEASE_MEMORY(x) \ #define RELEASE_MEMORY(x) \
if(nullptr == x) \ if(nullptr == x) \
{ \ { \

View File

@ -1,6 +1,9 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
#include <memory> #include <memory>
#include <cstring>
#define BUFFER_MAX 1024//每个包的最大包头 #define BUFFER_MAX 1024//每个包的最大包头
typedef enum { typedef enum {

View File

@ -16,6 +16,7 @@ extern "C"{
#include "third/include/event2/event.h" #include "third/include/event2/event.h"
#include "third/include/event2/thread.h" #include "third/include/event2/thread.h"
}; };
#include <iostream> #include <iostream>
#include "PackageReceiver.h" #include "PackageReceiver.h"
#include <mutex> #include <mutex>

View File

@ -8,3 +8,26 @@ string itos(int x){
itoa(x,buf,10); itoa(x,buf,10);
return string(buf); return string(buf);
} }
inline ENV_SYS CurrentEnvSys(){
#ifdef linux
return ENV_LINUX
#endif
#ifdef _WINDOWS
return ENV_WINDOWS
#endif
#ifdef _UNIX
return ENV_UNIX
#endif
}
inline ENV_COMPILER CurrentEnvCompiler(){
ifdef __GNUC__
return GCC;
#endif
ifdef _MSC_VER
return CL;
#endif
ifdef __clang__
return CLANG;
#endif
}