generallib/general/inc/utils.h

55 lines
873 B
C
Raw Permalink Normal View History

2019-12-21 10:50:15 +00:00
//
// Created by 29019 on 2019/5/2.
//
#ifndef CUTILS_UTILS_H
#define CUTILS_UTILS_H
#include <string>
#include "debug.h"
#include <sys/types.h>
2022-01-06 09:28:30 +00:00
#include <stdio.h>
#include <stdarg.h>
2019-12-21 10:50:15 +00:00
using namespace std;
// 字节序选择
typedef enum{
2022-03-28 03:14:02 +00:00
BIG_ENDIAN_TYPE, // 大端
LITTLE_ENDIAN_TYPE // 小端
}BYTE_ORDER_TYPE;
2019-12-21 10:50:15 +00:00
typedef enum {
ENV_WINDOWS = 1,
ENV_LINUX,
2020-08-30 07:13:54 +00:00
ENV_UNIX,
ENV_NONE,
}ENV_SYS;
typedef enum{
GCC = 1,
CLANG = 2,
2020-08-30 07:13:54 +00:00
CL = 3,
UNKNOWN
}ENV_COMPILER;
inline ENV_SYS CurrentEnvSys();
inline ENV_COMPILER CurrentEnvCompiler();
2019-12-21 10:50:15 +00:00
#define RELEASE_MEMORY(x) \
do { \
if(nullptr == x) \
{ \
delete(x); \
x = nullptr;\
} \
}while(0)
2019-12-21 10:50:15 +00:00
string itos(int x);
2022-03-28 03:14:02 +00:00
BYTE_ORDER_TYPE HostByteOrder();
2020-04-01 13:44:44 +00:00
2022-01-05 08:22:02 +00:00
// 限制float精确度
float LimitFloat(float in,int size);
2021-03-18 15:52:53 +00:00
2019-12-21 10:50:15 +00:00
#endif //CUTILS_UTILS_H