gpt4 book ai didi

c - 在函数内部使用具有相同参数名称的 extern

转载 作者:太空狗 更新时间:2023-10-29 15:38:34 27 4
gpt4 key购买 nike

我有这个带有全局变量的 C 代码

主程序.c

PLD po;
int main(){}

我在定义中有这个函数

函数定义.c

void function(PLD po)
{
extern po;
}

我的问题是,编译器如何知道它使用的是外部 po 还是参数 po??

最佳答案

如果你在不同的范围内声明它,你绝对可以访问外部变量。

void function(PLD po)
{

{
extern PLD po; //this is the po declared in main
}
}

关于c - 在函数内部使用具有相同参数名称的 extern,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22623459/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com