Draymonders / Code-Life

The marathon continues though.
27 stars 3 forks source link

c++ #define的好处是啥 #127

Open Draymonders opened 3 years ago

Draymonders commented 3 years ago

reference

https://bbs.csdn.net/topics/380157924

宏速度快~没有类型限制,缺点是不灵活,不知对否- -

优点:可完成函数调用的功能,又能减少系统开销,提高运行效率。因为它是在预处理阶段即进行了宏展开,在执行时不需要转换,即在当地执行。

缺点:所占用的目标代码空间相对较大

PS:牺牲空间来换取时间