大家好
就我的理解,inline 会直接将函数程式码展开,而非 jump 到他的位址
这么一来如果试着取得他的位址,是合理的动作吗
比方说
inline int add(int lhs, int rhs) {
return (lhs + rhs);
}
inline int sub(int lhs, int rhs) {
return (lhs - rhs);
}
int(*)(int, int) getOperator(char op) {
switch (op) {
case '+':
return &add;
case '-':
return ⊂
default:
return nullptr;
}
}
这样拿到的位址是有意义的吗
假如有,是否表示 binary 中有他的 symbol 可以连结,且 inline 就无效了
因为这两个函数很短,没有 inline 的话跑久了是不是会浪费很多时间
谢谢大家