question about boot_params global variables

Saad Masood saadahmed42 at gmail.com
Mon Nov 14 13:41:50 EST 2022


Hi Jim,
    In C, two global variables with the same name are converted to one
global variable (same memory address space).   So, the same variable is
referenced with or without the 'extern' keyword.

Thanks,



Saad

On Mon, Nov 14, 2022 at 11:23 AM <jim.cromie at gmail.com> wrote:

> On Tue, Aug 16, 2022 at 4:10 AM shiyu chou <shiyu2010310 at gmail.com> wrote:
> >
> > Hello all:
> > In arch x86 directory I found two global variables with the same
> name(master branch):
> > 1.arch/x86/boot/main.c
> > near line 18: struct boot_params boot_params
> __attribute__((aligned(16)));
> > 2.arch/x86/kernel/setup.c
> > near line 75: struct boot_params boot_params;
> > Is that wrong to define two global variables with the same name? And
> when use extern to reference the variable,which one did it reference?
> >
>
> hi, did you figure out a satisfactory answer ?
>
> what happens when you build with W=1 ?
>
>
> > _______________________________________________
> > Kernelnewbies mailing list
> > Kernelnewbies at kernelnewbies.org
> > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20221114/8ec795da/attachment.html>


More information about the Kernelnewbies mailing list