سؤال

I have this c code that have a global variable

main_prog.c

PLD po;
int main(){}

i have this function in the definition

functiondef.c

void function(PLD po)
{
  extern po;
}

what my problem is that how do the compiler know that it is using the extern po or the parameter po??

هل كانت مفيدة؟

المحلول

You can definitely access the extern variable if you declare it in a different scope.

void function(PLD po)
{

    {
        extern PLD po;    //this is the po declared in main
    }
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top