Do math functions of constant expressions get pre-calculated at compile time?

后端 未结 6 1118
感动是毒
感动是毒 2020-12-06 17:10

I tend to use math functions of constant expressions for convinience and coherence (i.e log(x)/log(2) instead of log(x)/0.3...). Since these functi

6条回答
  •  醉话见心
    2020-12-06 17:33

    This happens at runtime since the code for the function only becomes available during the linking step (which happens after the compile step).

    To optimize the step, use a global variable which you initialize before you use it.

提交回复
热议问题