putting function definitions in header files

后端 未结 4 494
情话喂你
情话喂你 2021-02-05 14:22

If you want to put function definitions in header files, it appears there are three different solutions:

  1. mark the function as inline
  2. mark the
4条回答
  •  忘了有多久
    2021-02-05 14:41

    static functions (equivalent to anonymous namespace) receive different copies for each TU. If the function is re-entrant this is basically identical (some compilers might have assembly-level differences) but if it isn't then it will have different static data for each TU. Inline functions are folded- that is, they have only one copy of static data for every TU.

提交回复
热议问题