Solved

Conditional Compilation

Posted on 2004-08-24
4
256 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 19

Expert Comment

by:drichards
ID: 11889423
0
 
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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now