Function needs to be static in release build but virtual in debug?

Discussion in 'C++' started by lygray, Jun 23, 2010.

  1. lygray

    lygray New Member

    Joined:
    Jun 23, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I have a quick question: I am working on a project where i need to do unit tests. I am trying to figure out a way to redefine the functions to virtual when unit testst are #defined, however, i am stuck with static.

    other than #defining a way to replace this word for all the source code, is there a way to get around this? In other words, a function foo needs to be static when used in the release but it needs to be virtual when used during unit testing. How can i acheive this?

    my first idea was using

    #ifdef unittest
    #define something_static virtual
    #else
    #define something_static static
    #endif

    but I am not very familiar with this language yet and want someone to maybe juggle my mind a little for other options...

    Thanks
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice