在motorware的例程中,看到的子函数都将传递的指针形参进行了Copy,不知是何用意。
bool GPIO_getData(GPIO_Handle gpioHandle, const GPIO_Number_e gpioNumber)
{
GPIO_Obj *gpio = (GPIO_Obj *)gpioHandle;
如红色字体的内容,这么做的目的是什么?有什么好处?如果直接使用gpioHandle有什么风险?
期待大神予以解答。
Susan Yang:In terms of Motorware, handles are nothing more than abstracted pointers to objects, without the additional typing and interpretation of the pointer syntax. The use of handles makes the code much more readable and understandable for most programmers.