Discussion:
const void * in structure
(too old to reply)
Skybuck Flying
2011-06-12 00:07:57 UTC
Permalink
Hello,

I come across the following C/C++ code which is a bit unfamiliar to me:

const void *SomeField2; // *

typedef struct SomeStructureName1 {
int SomeField1;
const void *SomeField2; // *
int SomeField3;
} SomeStructureName2;

It seems like a "constant void pointer type"

How to translate this structure to Delphi ?

My guess would be:

type
SomeStructureName1 = record
SomeField1 : integer;
SomeField2 : pointer;
SomeField3 : integer;
end;
SomeStructureName2 = SomeStructureName1;

Also is it just a "syntax" difference or is there a binary difference
between

1. void *
vs
2. const void *

?

Bye,
Skybuck.
RaZiel
2011-06-12 03:51:35 UTC
Permalink
Post by Skybuck Flying
Hello,
const void *SomeField2; // *
typedef struct SomeStructureName1 {
int SomeField1;
const void *SomeField2; // *
int SomeField3;
} SomeStructureName2;
It seems like a "constant void pointer type"
How to translate this structure to Delphi ?
type
SomeStructureName1 = record
SomeField1 : integer;
SomeField2 : pointer;
SomeField3 : integer;
end;
SomeStructureName2 = SomeStructureName1;
Also is it just a "syntax" difference or is there a binary difference
between
1. void *
vs
2. const void *
?
Bye,
Skybuck.
It's easier to read C++ declarations from right to left when pointers
are involved. So the type is "pointer to constant void".

- RaZ
Heinrich Wolf
2011-06-12 07:25:51 UTC
Permalink
Post by Skybuck Flying
Hello,
const void *SomeField2; // *
typedef struct SomeStructureName1 {
int SomeField1;
const void *SomeField2; // *
int SomeField3;
} SomeStructureName2;
It seems like a "constant void pointer type"
How to translate this structure to Delphi ?
type
SomeStructureName1 = record
SomeField1 : integer;
SomeField2 : pointer;
I agree.
Post by Skybuck Flying
SomeField3 : integer;
end;
SomeStructureName2 = SomeStructureName1;
Also is it just a "syntax" difference or is there a binary difference
between
1. void *
vs
2. const void *
no binary difference, just read-only.
Post by Skybuck Flying
?
Bye,
Skybuck.
Loading...