ignore code when compiling
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: ignore code when compiling

Threaded View

  1. #1
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,770

    ignore code when compiling

    In a rather large codebase, there is a set of recurring calls to a couple vararg functions (mainly for logging)

    Code:
       logthis(foo, bar(), somefunction(parameter1,parameter2), somethingelse);
    The number of parameters to this function is variable
    It has all types of variables, function calls, etc.
    The code has thousands of these lines



    There is now a need for a special version of the compile that will remove a lot of the code, among others is the logging.
    Can I somehow #define the "logthis" name into something that'll remove all actual calls to the code. including the actual parameters/expressions to the call.


    I can't afford to add #ifdef/#endif around each of the calls because there are too many of them, and because that'll cause some undisired side effects in our code conformance tests.

    Code:
    #define logthis __noop
    comes close, that removes the call, but it still causes the compiler to evaluate and validate all the parameters to the logthis function, which doesn't work because in this case, removing the logging headers also removes other members of the class that get used as part of the parameters to logthis()

    Ideal would be if I could define logthis into // resulting in all the rest of the line being comments, but that doesn't work. But it's basically something like that which I'm seeking.

    Preferably I'd like something to be portable, but I'll take a solution that only works on visual studio as well.
    Last edited by OReubens; September 7th, 2012 at 06:53 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center