Hi, I'm having exercise where I have to check name lengths of external and local names.
What is the longest local name you can use in a C++ program on your system?
What is the longest external name you can use in a C++ program on your system?
Are there any restrictions on the characters you can use in a name?
First of all as i understand local names are something that are defined inside a function or lambda (according to Stroustrup's "The C++ programming language 4th edition" page 157) but i didnt find anything usefull about external names. Except that they were mentioned in this great resource https://msdn.microsoft.com/en-us/library/bc2y4ddf.aspx so i understand that external is kind of synonym of public but I'm having doubts about that.
1. Would be cool to know what did Stroustrup meant by external name lenght.
2. I checked manually how long are these 2 names
1 2 3 4 5 6 7
//4095 characters
externint name_external_maybe . . . 4095;
int main() {
//4095 characters
int name_local . . . 4095;
}
Is there a better way to check the max lengths of names? I checked in std::numeric_limits but nothing seemed to help.
Anyway if someone knows something about this I would appreciate some answers. Thanks
You have the right idea. External means a global name.
To check this properly, I suggest that you create TWO names that differ only by the last character. Modify one variable, then print them both. Then modify the other and print them both.
For the external name, define it in one file and use it in another.