Re: global variable in kernel

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

 



On Mon, Jul 12, 2004 at 21:12:07 -0600, Sharma Sushant wrote:
> Hi All
> 
> I am trying to declare a global variable g_sklist *sklist in 
> net/core/dev.c
> 
> g_sklist is a struct which i have defined in include/linux/skbuff.h
> 
> I am allocating memory for this structure and assigning values to it in 
> dev.c file (inside a function).
> 
> Then I am trying to acess it by declaring it as
> extern g_sklist *sklist in file kernel/sched.c

You should always do that in a header which is also included in the file
that defines the variable. That way compiler can checks some things for
you.

> but I am getting NULL here.  Can some one explain where 
> am I wrong
> or some other way to access global variables inside kernel.

No, there is no other way. Your description seems correct. Are you sure,
that the function that initializes the pointer was already called?

On Mon, Jul 12, 2004 at 21:12:07 -0600, Sharma Sushant wrote:
> ps:please cc the reply to me

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

Attachment: signature.asc
Description: Digital signature


[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