Originally Posted by
dayalsoap
Right, I don't want them to be accessible to other files. Each one has its own myrank and num_ranks, etc.
In this case another of tabstop's suggestions applies:
Originally Posted by
tabstop
Did you intend to have two completely different set of variables at file scope? If so, mark them static (which will close them off to other translation units).
However, in C++ we tend to prefer the use of an unnamed namespace instead, e.g.,
Code:
namespace
{
int myrank, num_ranks;
}
That said, why do you need to do this? Why are these variables not local variables, or perhaps encapsulated within a class?