1

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?

jean
  • 101
  • 5

2 Answers2

3

You cannot. Copy the header and add extern yourself.

Dark Falcon
  • 43,592
  • 5
  • 83
  • 98
  • It's kind of nonstandard for header files to be written the way you describe for just this reason. Normally you'd want the header file to have every global declared with `extern`, and then have the actual variable storage declarations made in an implementation file elsewhere. – Carl Norum Oct 16 '09 at 00:28
0

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.

Mark Bessey
  • 19,598
  • 4
  • 47
  • 69