Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Conditional Compilation

Posted on 2004-08-24
4
Medium Priority
?
266 Views
Last Modified: 2010-04-23
I was wondering if there was an equivalent way to do this C++ code in VB.

#if _DEBUG
      #define RunMethod(x) RunMethodA(x)
#else
      #define RunMethod(x) x
#endif

The main reason I wish to do this is I will be writing a testing suite and I will be writing these functions into if statements
eg. if TestCondition(3>4) then
So when I compile it in Debug it will call TestCondition, but when it is compiled to Release mode it change to "if 3>4 then". The other reason I really need it done like this instead of just returning straight away from inside the TestCondition function if compiled in release mode is that the file which will contain the function shall be removed from the source before the Release version is compiled

0
Comment
Question by:Mike737
  • 2
4 Comments
 
LVL 1

Author Comment

by:Mike737
ID: 11889446
Still doesn't solve my issue.
I need the #define specifically.

If I was to do it just as a #if,#else everytime for every if statment I write the extra number of lines I would have to write would be rediculous! I would be looking at an extra 300 lines in my code if I had 100 if statements in it.

I don't really think that just #if's by themselves are an acceptable soloution.

0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 1000 total points
ID: 11893566
no you cannot do the above as code macros are not supported ...

you can however use the Conditional attribute on your classes (they will completely compile out including calls to them if symbol not set) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsconditionalattributeclasstopic.asp includes examples. This should do exactly what you are looking for.
0
 
LVL 1

Author Comment

by:Mike737
ID: 11899659
Looks like you are on the right track with that one.
Been able to get a nice little testing interface up and working with that one.

Absolutely awesome answer dude!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Loops Section Overview

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question