All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] What do "#if 1" and "#if 0" do?
@ 2007-03-28  7:24 Guanqun Lu
  2007-03-28  7:47 ` Matthias Kaehlcke
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Guanqun Lu @ 2007-03-28  7:24 UTC (permalink / raw)
  To: kernel-janitors

I found the webpage:
http://fsdev.net/wiki/index.php?title=If_0_or_if_1_directives
And I'm just wondering what do the two directives do.

Thanks.
-- 
Guanqun
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [KJ] What do "#if 1" and "#if 0" do?
  2007-03-28  7:24 [KJ] What do "#if 1" and "#if 0" do? Guanqun Lu
@ 2007-03-28  7:47 ` Matthias Kaehlcke
  2007-03-28  7:54 ` Yoann Padioleau
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Matthias Kaehlcke @ 2007-03-28  7:47 UTC (permalink / raw)
  To: kernel-janitors

El Wed, Mar 28, 2007 at 07:24:35AM +0000 Guanqun Lu ha dit:

> I found the webpage:
> http://fsdev.net/wiki/index.php?title=If_0_or_if_1_directives
> And I'm just wondering what do the two directives do.

my interpretation is that they are used for activating (#if 1) and
deactivating (#if 0) code.

m.

-- 
              Insanity: doing the same thing over and over
                again and expecting different results
                            (Albert Einstein)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [KJ] What do "#if 1" and "#if 0" do?
  2007-03-28  7:24 [KJ] What do "#if 1" and "#if 0" do? Guanqun Lu
  2007-03-28  7:47 ` Matthias Kaehlcke
@ 2007-03-28  7:54 ` Yoann Padioleau
  2007-03-28  8:28 ` Guanqun Lu
  2007-03-28 12:50 ` Robert P. J. Day
  3 siblings, 0 replies; 5+ messages in thread
From: Yoann Padioleau @ 2007-03-28  7:54 UTC (permalink / raw)
  To: kernel-janitors

Matthias Kaehlcke <matthias.kaehlcke@gmail.com> writes:

> El Wed, Mar 28, 2007 at 07:24:35AM +0000 Guanqun Lu ha dit:
>
>> I found the webpage:
>> http://fsdev.net/wiki/index.php?title=If_0_or_if_1_directives
>> And I'm just wondering what do the two directives do.
>
> my interpretation is that they are used for activating (#if 1) and
> deactivating (#if 0) code.

We often use #if 0 ... #endif for commenting a big region of code.
One might think that we could also use /* ... */ but if what is in the middle
contain some C comments, then you can not, because C does not
handle nested comments.

>
> m.
>
> -- 
>               Insanity: doing the same thing over and over
>                 again and expecting different results
>                             (Albert Einstein)
>                                                                  .''`.
>     using free software / Debian GNU/Linux | http://debian.org  : :'  :
>                                                                 `. `'`
> gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
> _______________________________________________
> Kernel-janitors mailing list
> Kernel-janitors@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [KJ] What do "#if 1" and "#if 0" do?
  2007-03-28  7:24 [KJ] What do "#if 1" and "#if 0" do? Guanqun Lu
  2007-03-28  7:47 ` Matthias Kaehlcke
  2007-03-28  7:54 ` Yoann Padioleau
@ 2007-03-28  8:28 ` Guanqun Lu
  2007-03-28 12:50 ` Robert P. J. Day
  3 siblings, 0 replies; 5+ messages in thread
From: Guanqun Lu @ 2007-03-28  8:28 UTC (permalink / raw)
  To: kernel-janitors

On 3/28/07, Cong WANG <xiyou.wangcong@gmail.com> wrote:
> 2007/3/28, Guanqun Lu <guanqun.lu@gmail.com>:
> > On 3/28/07, Cong WANG <xiyou.wangcong@gmail.com> wrote:
> > > 2007/3/28, Guanqun Lu <guanqun.lu@gmail.com>:
> > > Maybe for debugging. ;-p
>
> That's another way. ;-p
>
> Consider that you are programming for a large project, such as linux
> kernel. Makefiles are already well written. If you want to add -DDEBUG
> to gcc, you must modify the corresponding makefile. But if you use
> '#if 0' for debugging, you can modify the code, change '#if 0' to '#if
> 1', to do debugging.
>
>
> --
> So Dark The Con Of Man.
>
Oh... I see the point.

Thanks a lot, wang and Yoann.

-- 
Guanqun
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [KJ] What do "#if 1" and "#if 0" do?
  2007-03-28  7:24 [KJ] What do "#if 1" and "#if 0" do? Guanqun Lu
                   ` (2 preceding siblings ...)
  2007-03-28  8:28 ` Guanqun Lu
@ 2007-03-28 12:50 ` Robert P. J. Day
  3 siblings, 0 replies; 5+ messages in thread
From: Robert P. J. Day @ 2007-03-28 12:50 UTC (permalink / raw)
  To: kernel-janitors

On Wed, 28 Mar 2007, Yoann Padioleau wrote:

> Matthias Kaehlcke <matthias.kaehlcke@gmail.com> writes:
>
> > El Wed, Mar 28, 2007 at 07:24:35AM +0000 Guanqun Lu ha dit:
> >
> >> I found the webpage:
> >> http://fsdev.net/wiki/index.php?title=If_0_or_if_1_directives
> >> And I'm just wondering what do the two directives do.
> >
> > my interpretation is that they are used for activating (#if 1) and
> > deactivating (#if 0) code.
>
> We often use #if 0 ... #endif for commenting a big region of code.
> One might think that we could also use /* ... */ but if what is in
> the middle contain some C comments, then you can not, because C does
> not handle nested comments.

there's that, and there's also that there are unquestionably
*hundreds* of those "#if 0" tests that have been there for a long time
and lost any value they might have had once.

and let's not even talk about all those "#if 1"s ... :-)

rday
-- 
====================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
====================================
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-03-28 12:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-28  7:24 [KJ] What do "#if 1" and "#if 0" do? Guanqun Lu
2007-03-28  7:47 ` Matthias Kaehlcke
2007-03-28  7:54 ` Yoann Padioleau
2007-03-28  8:28 ` Guanqun Lu
2007-03-28 12:50 ` Robert P. J. Day

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.