Re: Understanding #ifdef in .h files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le Fri, 20 Jun 2014 18:44:35 +0530,
Pranay Srivastava <pranjas@xxxxxxxxx> a écrit :

> On Fri, Jun 20, 2014 at 6:29 PM, Harold André <harold.andre@xxxxxx>
> wrote:
> > Le Fri, 20 Jun 2014 16:36:58 +0530,
> > Pranay Srivastava <pranjas@xxxxxxxxx> 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 !

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies





[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux