Re: [RFC]confusions about 'struct' define

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

 



Foward declaration, that is.

You can vaguely compare it to function prototypes.

On 1 June 2012 15:00, Bernd Petrovitsch <bernd@xxxxxxxxxxxxxxxxxxx> wrote:
> Hi!
>
> On Don, 2012-05-31 at 01:37 +0800, harryxiyou wrote:
>> On Thu, May 31, 2012 at 1:20 AM, Gaurav Jain <gjainroorkee@xxxxxxxxx> wrote:
> [...]
>> > Those are forward declarations as they are being used in defining struct
>> > bus_attribute. It's nothing special about GNU-C. That's the case for ANSI-C
>> > too. Pretty standard.
>
> These actually exists since K&R times.
>
>> Hmmm.., that is to say, they may be used before definitions in this file or
>> defined in other files like 'struct iommu_ops;' field (Actually, i can
>
> Yes, that's the only reason. And you can't use it if you need the actual
> size of that struct because the compiler doesn't know it (yet).
> The main usage scenario is if you need a pointer to it.
>
>> not find this field's
>> definition in this file). However, if it has been defined in other
>> header files, we need
>> not declare here, right?
>
> If you #include that other file, yes.
> But it is not trivial in very large projects like the Linux kernel to
> keep somewhat logical and clean and circular-free -h files.
> And you also do not really want a separate .h file for each struct.
>
>        Bernd
> --
> Bernd Petrovitsch                  Email : bernd@xxxxxxxxxxxxxxxxxxx
>                     LUGA : http://www.luga.at
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@xxxxxxxxxxxxxxxxx
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

_______________________________________________
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