1

Topic: How to set variable value which defines length of an array?

2

Re: How to set variable value which defines length of an array?

AlekseySQL;
So it is not necessary. After all you, actually, rely on  which connects a variable to real value from any.cpp a file or library which will be accessible at the moment of loading . But it is necessary for the compiler, each time when the next unit of translation includes this , it should define precisely the size of structure under the available data, and, it turns out that the size rolls in any left unit of translation.
Really simply to the structure declaration it is impossible to make something for example

const int LengthOfClient = 3;
struct allData final
{
char Client [LengthOfClient];
};

Consider that the size should be is mandatory  and determined on a compilation stage.

3

Re: How to set variable value which defines length of an array?

NekZ wrote:

AlekseySQL;
So it is not necessary. After all you, actually, rely on  which connects a variable to real value from any.cpp a file or library which will be accessible at the moment of loading . But it is necessary for the compiler, each time when the next unit of translation includes this , it should define precisely the size of structure under the available data, and, it turns out that the size rolls in any left unit of translation.
Really simply to the structure declaration it is impossible to make something for example

const int LengthOfClient = 3;
struct allData final
{
char Client [LengthOfClient];
};

Consider that the size should be is mandatory  and determined on a compilation stage.

Thanks, but at me this h - a file then in some places  and consequently turns out plural determination. To use indeterminate name spaces also it does not turn out: in other units I should know the size of an array (to organize cycles).

4

Re: How to set variable value which defines length of an array?

AlekseySQL wrote:

Thanks, but at me this h - the file then in some places  and consequently turns out plural determination. To use indeterminate name spaces also it does not turn out: in other units I should know the size of an array (to organize cycles).

You are precisely assured what at you plural determination turns out, to you  about it told?
Global const objects in a C ++ have internal  if are not declared as extern.

http://eel.is/c draft/basic.link#3 wrote:

A name having namespace scope has internal linkage if it is the name of
(3.1)
a variable, function or function template that is explicitly declared static; or;
(3.2)
a non-inline variable of non-volatile const-qualified type that is neither explicitly declared extern nor previously declared to have external linkage ; or
(3.3)
a data member of an anonymous union.

5

Re: How to set variable value which defines length of an array?

NekZ wrote:

You are precisely assured what at you plural determination turns out, to you  about it told?
Global const objects in a C ++ have internal  if are not declared as extern.
it is passed...

Thanks, did not know that constant it is possible not to do global objects extern.