Declaring abstract class (pure virtual method) increase binary size substantially

前端 未结 2 1858
无人及你
无人及你 2021-01-02 11:46

Here is the story: I am developing C++ software for ARM Cortex-M0 processor in Linux with AC6 Toolpack. Before I was using Keil (in windows) (who has their own toolchain) a

2条回答
  •  太阳男子
    2021-01-02 12:33

    As far as I understand, when you make your virtual function in base class pure you create the potential for making a pure virtual call. So compiler generates code where it prints message about pure virtual call fact, demangled names for function and class and may be something else. It adds bunch of functions to your binary for that, so size increases.

    I suggest to add empty implementation to your pure virtual function - may be it prevents compiler from doing that stuff.

提交回复
热议问题