C语言平台移植篇 - 数据类型重定义

背景说明

相比大家在在实际项目中,会碰到由于种种原因,项目中需要更换芯片,一般代码量比较小的时候我们通常会重新写符合该芯片的项目工程。但是假如项目较大或者芯片平台很多的时候,这是时候就要求我们,将C语言一些基础的命令字重新定义,不依赖于芯片平台。

案例代码

一般都为.h文件作为定义

#ifndef __LIHGT_TYPES_H__
#define __LIHGT_TYPES_H__

#include <stdio.h>
#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif  /* __cplusplus */

#ifndef WEAK
#define WEAK __attribute__((weak))
#endif
//#ifndef WEAK
//#define WEAK weak
//#endif


typedef int OPERATE_LIGHT;

#ifndef LIGHT_OK
#define LIGHT_OK                             (0)
#endif
#ifndef LIGHT_COM_ERROR
#define LIGHT_COM_ERROR                      (-1)
#endif
#ifndef LIGHT_INVALID_PARM
#define LIGHT_INVALID_PARM                   (-2)
#endif
#ifndef LIGHT_MALLOC_FAILED
#define LIGHT_MALLOC_FAILED                  (-3)
#endif
#ifndef LIGHT_NOT_FOUND
#define LIGHT_NOT_FOUND                      (-901)
#endif

#ifndef VOID
typedef void VOID;
#endif
typedef void *PVOID_T;

#ifndef bool_t
typedef int bool_t;
#endif

typedef bool_t BOOL_T;
typedef BOOL_T *PBOOL_T;

typedef char CHAR_T;
typedef signed char SCHAR_T;
typedef unsigned char UCHAR_T;
typedef char *PCHAR_T;

typedef short SHORT_T;
typedef unsigned short USHORT_T;
typedef short *PSHORT_T;

typedef signed int INT_T;
typedef int *PINT_T;
typedef unsigned int UINT_T;
typedef unsigned int *PUINT_T;

typedef long LONG_T;
typedef unsigned long ULONG_T;
typedef long *PLONG_T;

typedef unsigned short WORD_T;
typedef WORD_T *PWORD_T;
typedef unsigned int DWORD_T;
typedef DWORD_T *PDWORD_T;

typedef float FLOAT_T;
typedef FLOAT_T *PFLOAT_T;

typedef long long DLONG_T;
typedef DLONG_T *PDLONG_T;

typedef unsigned long long DDWORD_T;
typedef DDWORD_T *PDDWORD_T;

typedef int OPERATE_RET;

typedef double DOUBLE_T;

#ifndef IN
#define IN 
#endif

#ifndef OUT
#define OUT
#endif


#ifndef FALSE
#define FALSE 0
#endif

#ifndef TRUE
#define TRUE 1
#endif

#ifndef INOUT
#define INOUT
#endif

#ifndef VOID
#define VOID void
#endif

#ifndef CONST
#define CONST const
#endif

#ifndef STATIC
#define STATIC static
#endif

#ifndef SIZEOF
#define SIZEOF sizeof
#endif

#ifndef INLINE
#define INLINE inline
#endif

#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif

#ifndef true
#define true 1
#endif

#ifndef false
#define false 0
#endif

#define PIN_NOEXIST        0xFF  ///< default pin def



#ifdef __cplusplus
}
#endif /* __cplusplus */


#endif  /* __LIHGT_TYPES_H__ */

案例说明

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值