Including header file with global variable

萝らか妹 提交于 2019-12-24 08:49:30

问题


I need to include a header file that contains some global variables (not mine so I cannot change it).

How do I do this so that the variables within the included file are considered 'extern' in all but one case?


回答1:


You cannot. Copy the header and add extern yourself.




回答2:


If the variables are only declared in the header, but aren't assigned a value, then you might be able to do this, depending on the compiler. GCC, for example, has the -fno-common flag to control this behavior.



来源:https://stackoverflow.com/questions/1575766/including-header-file-with-global-variable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!