All of lore.kernel.org
 help / color / mirror / Atom feed
From: harold.andre@gmx.fr (Harold André)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Understanding #ifdef in .h files
Date: Fri, 20 Jun 2014 15:58:47 +0200	[thread overview]
Message-ID: <20140620155847.4607b889@debian-desktop> (raw)
In-Reply-To: <CA+aCy1Eo=C8mApXFxHq3KNZJbSWwWE9PB74+29Y+x6CbVf8ihQ@mail.gmail.com>

Le Fri, 20 Jun 2014 18:44:35 +0530,
Pranay Srivastava <pranjas@gmail.com> a ?crit :

> On Fri, Jun 20, 2014 at 6:29 PM, Harold Andr? <harold.andre@gmx.fr>
> wrote:
> > Le Fri, 20 Jun 2014 16:36:58 +0530,
> > Pranay Srivastava <pranjas@gmail.com> a ?crit :
> >
> >
> >> You say here you will define the function else where if
> >> TEST_FUNCTION is defined
> >>
> >> >     #ifdef TEST_FUNCTION
> >> >     void test(int *value);
> >> >     #else
> >> >     static inline void test(int *value) { }
> >> >     #endif
> >> >
> >> > test_ifdef.c:
> >> >
> >> >     #include "test_ifdef.h"
> >> >
> >> But here you do on and define it any way. You must stick to the
> >> rule you created earlier. If you are defining it here then this
> >> must also be under the test of ifdef TEST_FUNCTION
> >> >     void test(int *value)
> >> >     {
> >> >         *value += 1;
> >> >     }
> >> >
> >
> > Thank you Pranay for your answer. I understand this now.
> >
> > But when i look at the kernel code, i don't see ifdef test around
> > the definition of the function. For example, i look for the function
> > "hiddev_hid_event":
> >
> > In include/linux/hiddev.h:
> > #ifdef CONFIG_USB_HIDDEV
> > ...
> > void hiddev_hid_event(struct hid_device *hid, struct hid_field
> > *field, struct hid_usage *usage, __s32 value);
> > ...
> > #else
> > ...
> > static inline void hiddev_hid_event(struct hid_device *hid, struct
> > hid_field *field, struct hid_usage *usage, __s32 value) { }
> > ...
> > #endif
> >
> > In drivers/hid/usbhid/hiddev.c:
> > /*
> >  * This is where hid.c calls into hiddev to pass an event that
> > occurred over
> 
> That's right but the magic doesn't happen here :-)
> 
> if you see usbhid/Makefile you'll understand what I mean :-). If not ,
> please do ask.

Ah yes !! Ok, i understand !! ;-)
Thank Pranay for sharing your knowledge !

      reply	other threads:[~2014-06-20 13:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-20 10:58 Understanding #ifdef in .h files Harold André
2014-06-20 11:06 ` Pranay Srivastava
2014-06-20 12:59   ` Harold André
2014-06-20 13:14     ` Pranay Srivastava
2014-06-20 13:58       ` Harold André [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140620155847.4607b889@debian-desktop \
    --to=harold.andre@gmx.fr \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.