简体   繁体   中英

Including header file with global variable

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?

You cannot. Copy the header and add extern yourself.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM