Re: structure definition in a .c file rather than .h file

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

 



Look for 'forward declaration' of variables in C.
You are telling the compiler that "I am declaring such a structure. Understand it when you encounter it" . 

- Durga



From: Sukanto Ghosh <sukanto.cse.iitb@xxxxxxxxx>
To: Nelson Castillo <nelsoneci@xxxxxxxxx>; Pei Lin <telent997@xxxxxxxxx>
Cc: kernelnewbies <kernelnewbies@xxxxxxxxxxxx>
Sent: Thursday, March 12, 2009 3:06:46 PM
Subject: Re: structure definition in a .c file rather than .h file

On Thu, Mar 12, 2009 at 11:58 AM, Nelson Castillo <nelsoneci@xxxxxxxxx> wrote:
> On Thu, Mar 12, 2009 at 2:06 PM, Sukanto Ghosh
> <sukanto.cse.iitb@xxxxxxxxx> wrote:
>> Hi,
>>
>> The complete definition of structure cfs_rq is in a .c file
>> (kernel/sched.c). In the head linux/sched.h it has been declared as
>> "struct cfs_rq;"
>> What is the purpose of doing so ?
>
> With this declaration in linux/sched.h you can make pointers of the
> structure anywhere. All pointers have the same size thus it just
> doesn't matter if you don't know the details of the structure.
>
> The idea of not exposing the structure is just encapsulation. It means
> you shouldn't be touching those fields outside kernel/sched.c unless
> you use one of the provided API functions to do so (if any).
>

exactly, and yet the fields have been used in kernel/sched_fair.c
.... this is what confuses me


--
Regards,
Sukanto Ghosh

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[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