cherry-embedded / CherryUSB

CherryUSB is a tiny and portable USB Stack (device & host) for embedded system with USB IP

Home Page:https://cherryusb.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WBVAL & DBVAL

wyl2008056 opened this issue · comments

usb_util.h文件中,如下两个宏定义有bug,需要对x添加括号,182~183行
#define WBVAL(x) (x & 0xFF), ((x >> 8) & 0xFF)
#define DBVAL(x) (x & 0xFF), ((x >> 8) & 0xFF), ((x >> 16) & 0xFF), ((x >> 24) & 0xFF)

修改如下:
#define WBVAL(x) ((x) & 0xFF), (((x) >> 8) & 0xFF)
#define DBVAL(x) ((x) & 0xFF), (((x) >> 8) & 0xFF), (((x) >> 16) & 0xFF), (((x) >> 24) & 0xFF)

不需要修改,没有问题。

这都用了2年了多了,写法不存在问题

你可以github上随便找这些code,有加的有不加的,没有影响的

如果你的x不是一个值而是表达式,这边是有问题的,但是我这边禁止使用表达式