Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Does "#if 1 func1 #else func2 #endif execute func1 during executation?

Reply
Thread Tools

Does "#if 1 func1 #else func2 #endif execute func1 during executation?

 
 
Mr. Ken
Guest
Posts: n/a
 
      09-06-2006
In the file I received, it defines two versions of same function with such
statement.
Is it during compilation, func1 will be used?

#if 1
func1.....
#else
func1.....
#endif

Sorry for the silly question but I am a little confused now.



 
Reply With Quote
 
 
 
 
Bart
Guest
Posts: n/a
 
      09-06-2006
Mr. Ken wrote:
> In the file I received, it defines two versions of same function with such
> statement.
> Is it during compilation, func1 will be used?
>
> #if 1
> func1.....
> #else
> func1.....
> #endif
>
> Sorry for the silly question but I am a little confused now.


Here the first version (#if 1) will be compiled and the second version
(#else) will be ignored. The function will not be used at compile time.
This is just a way to compile a different version of the function.

Regards,
Bart.

 
Reply With Quote
 
 
 
 
Mr. Ken
Guest
Posts: n/a
 
      09-06-2006

"Bart" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Mr. Ken wrote:
> > In the file I received, it defines two versions of same function with

such
> > statement.
> > Is it during compilation, func1 will be used?
> >
> > #if 1
> > func1.....
> > #else
> > func1.....
> > #endif
> >
> > Sorry for the silly question but I am a little confused now.

>
> Here the first version (#if 1) will be compiled and the second version
> (#else) will be ignored. The function will not be used at compile time.
> This is just a way to compile a different version of the function.
>
> Regards,
> Bart.
>


Thank you Bart.



 
Reply With Quote
 
bharath.donnipad@gmail.com
Guest
Posts: n/a
 
      09-07-2006

Mr. Ken wrote:
> "Bart" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> > Mr. Ken wrote:
> > > In the file I received, it defines two versions of same function with

> such
> > > statement.
> > > Is it during compilation, func1 will be used?
> > >
> > > #if 1
> > > func1.....
> > > #else
> > > func1.....
> > > #endif
> > >
> > > Sorry for the silly question but I am a little confused now.

> >
> > Here the first version (#if 1) will be compiled and the second version
> > (#else) will be ignored. The function will not be used at compile time.
> > This is just a way to compile a different version of the function.
> >
> > Regards,
> > Bart.
> >

>
> Thank you Bart.


Code under #if 1 always compiles and gets embedded in to object file.
You may find #if 0 in some code where in the code under it will not
compile.

- Bharath

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute <script> during runtime. batham Javascript 5 12-21-2005 06:26 PM
button.onclick = new Function("func2()") + button.onclick foldface@yahoo.co.uk Javascript 2 09-26-2005 08:13 AM
Is A.func1(param1).func2(param2.)func3.(param3) legal ??? bluekite2000@gmail.com C++ 3 05-18-2005 04:31 PM
XML-RPC - java.lang.ClassCastException: java.util.Date error during execute mgalaty Java 0 09-10-2004 01:26 AM
Can i execute aspx file in my asp pag with server.execute method(sorry) Savas Ates ASP General 1 08-17-2004 04:52 PM



Advertisments