Boost unit testing main function?

后端 未结 4 1975
[愿得一人]
[愿得一人] 2021-01-11 16:51

How do I define my own main() function when testing with boost?

Boost is using it\'s own main function, but I\'m using a custom memory manager and it ne

4条回答
  •  庸人自扰
    2021-01-11 17:17

    Memory can be allocated before main:

    static int* x = new int(1);
    int main() { return *x; }
    

    And you could make your memory manager a global variable as well,
    but you can't enforce a specific order of global variables initialization. (in standard C++ at least)

    In Windows you could put your memory manager into a DLL, at it will be initialized before application entry point will be called, but still, something other may allocate a memory before - another DLL, or CRT of your DLL.

提交回复
热议问题