1

Topic: Transmission under the link

Good afternoon dear programmers.
I have an exterior method with the signature
func (char *thePointer);
I want to create on a stack a type array long [] and to transfer the link to it in it a method
Prompt as it correctly to make?
Thanks.

2

Re: Transmission under the link

Understood, thanks.

3

Re: Transmission under the link

Simeon. ;
Itself thought, itself solved. Asked a question - write the answer.
and that so is boring on this branch when everywhere plow open spaces...

4

Re: Transmission under the link

Yes a question that for a beginner
I supposed that local gurus With ++ should such know
I generally  With ++ only start to learn that and consequently foolish questions I set here

5

Re: Transmission under the link

.  wrote:

I supposed that local gurus With ++ should such know

Show as made, and gurus if needed produce recommendations

6

Re: Transmission under the link

Simeon. ;

wrote:

I want to create on a stack...

Only remember, how many he lives.
In About an array and the pointer on 1 an element - one and too. And storage track.
Links is hardly another (the difference easy, but is)

7

Re: Transmission under the link

wrote:

it is passed...
Show as made, and gurus if needed produce recommendations

long buffer [8];
char *pointer = reinterpret_cast <char *> (&buffer);
func (pointer);
On idea while we from below a stack that that on top should not be remote
Launched  and works
If crookedly wrote strongly do not beat smile
I the beginner in pluses

8

Re: Transmission under the link

Simeon. ;
Could write easier

func ((char *) buffer);

It is more important, as you will interpret it then.

9

Re: Transmission under the link

Siemargl wrote:

Simeon. ;
Could write easier

func ((char *) buffer);

It is more important, as you will interpret it then.

I transfer the pointer in exterior
She expects it as a flow byte.
And in what a difference between my and your approach?
I where read that reinterpret_cast absolutely not well to use
However opened some projects on  and there with might and main this construction use.

10

Re: Transmission under the link

.  wrote:

and in what a difference between my and your approach?
I where read that reinterpret_cast absolutely not well to use.

There where it is written, forgot to add that reinterpret_cast <T *> it is bad, and (T *) is even worse smile
Also did not specify that "badly" is not categorical badly, and caution by a beginner is simple smile
Also forgot to add that is is specific reinterpret_cast <char *> - generally well since does not break strict aliasing: https://ru.stackoverflow.com/questions/ … t-aliasing
So the code at you true.

11

Re: Transmission under the link

.  wrote:

and in what a difference between my and your approach?

Yours - a C ++. It is With.

12

Re: Transmission under the link

Dimitry Sibiryakov wrote:

it is passed...
Yours - a C ++. It is With.

I would tell that in both cases, function as argument will manage the same address.
Proceeding from it, it would be possible not to encode at all, and to write down explicitly:

union param_u {
long buffer [8];
char str [1];
} param;
func (param.str);

13

Re: Transmission under the link

.  wrote:

good afternoon dear programmers.
I have an exterior method with the signature
func (char *thePointer);
I want to create on a stack a type array long [] and to transfer the link to it in it a method
Prompt as it correctly to make?
Thanks.

In any way.
I hope, you  are correct

14

Re: Transmission under the link

MasterZiv;
In any way?
How many councils gave already

15

Re: Transmission under the link

.  wrote:

MasterZiv;
In any way?
How many councils gave already

Some  consider that the bad style
Still to the bad I will teach:
If selection of storage with a size, undefined at a compilation stage is necessary, in the majority of compilers is supported alloca

16

Re: Transmission under the link

kealon (Ruslan) wrote:

Some  consider that the bad style

And how it is correct?
To select char [] on a stack?

17

Re: Transmission under the link

.  wrote:

it is passed...
And how it is correct?
To select char [] on a stack?

I think MasterZiv has judgement against the idea, but probably it would be better if he explained
and as it to make in case of need - at you already is the whole two methods

18

Re: Transmission under the link

And than the idea that is bad?
Well I do not want in  an array to select - unproductively it

19

Re: Transmission under the link

.  wrote:

and than the idea that is bad?

In the size of the stack. It only 1 MB on-default.
Do not forget about it if arrays on the stack you will allocate.

20

Re: Transmission under the link

Dima T wrote:

it is passed...
In the size of the stack. It only 1 MB on-default.
Do not forget about it if arrays on the stack you will allocate.

So at me the size  16 byte
The length is fixed

21

Re: Transmission under the link

.  wrote:

and than the idea that is bad?
Well I do not want in  an array to select - unproductively it

Not such and the big losses.
But yes, on a stack faster though and not so it is safe in the long term

22

Re: Transmission under the link

And the recursion is safe?
We create a method with two parameters
method (long t1, long t2)
On each iteration of a recursion we receive plus the same of 16 byte
Citizens you that?

23

Re: Transmission under the link

.  wrote:

and the recursion is safe?

It is absolutely safe, if the enclosure allowed level is supervised as much as possible. And without such control it also do not use. Well, behind an exception, unless, students)

24

Re: Transmission under the link

ptr128;
And how this depth by the way competently to supervise?
Simply regulating depth of an enclosure through  parameter?

25

Re: Transmission under the link

.  wrote:

ptr128;
And how this depth by the way competently to supervise?

Depends on the compiler and from a platform. Under Linux function getrlimit is accessible (), in Windows it is possible to use VirtualQuery (), on microcontrollers simply I consider directly, using the size of the static unit, the pointer of a stack and an amount of operative storage.