C常用宏定义 Standard Macros — commonly-used macros

摘自:https://developer.gnome.org/glib/stable/glib-Standard-Macros.html

#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '/')

Checks whether a character is a directory separator. It returns TRUE for '/' on UNIX machines and for '\' or '/' under Windows.

 

#define MIN(a, b)  (((a) < (b)) ? (a) : (b))

Calculates the minimum of a and b .

 

#define MAX(a, b)  (((a) > (b)) ? (a) : (b))

Calculates the maximum of a and b .

 

#define ABS(a)	   (((a) < 0) ? -(a) : (a))

Calculates the absolute value of a . The absolute value is simply the number with any negative sign taken away.

#define CLAMP(x, low, high)  (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))

Ensures that x is between the limits set by low and high . If low is greater than high the result is undefined.

 

数据类型定义:[来自https://www.microchip.com/webdoc/AVRLibcReferenceManual/group__avr__stdint.html]

typedef signed char int8_t 
typedef unsigned char uint8_t 
typedef signed int int16_t 
typedef unsigned int uint16_t 
typedef signed long int int32_t 
typedef unsigned long int uint32_t 
typedef signed long long int int64_t 
typedef unsigned long long int uint64_t 

 

发布了25 篇原创文章 · 获赞 11 · 访问量 5万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览