I have a struct buffer, and I want to print out its members' offsetof.
This:
foreach(i,_t; buffer.tupleof) {
writefln("%s@: %s", _t.stringof, _t.offsetof);
}
complains
Error: undefined identifier 'offsetof'
what should I be doing?
t; It's actually exactly the opposite from how it's defined in the spec:
> you
> can only use offsetof on instances of user-defined types, not on the
> type
> itself.
>
> It makes _absolutely_ no sense, I know. I can't help but feel it's a
> bug,
>
On Fri, Nov 7, 2008 at 8:59 PM, Tim M <[EMAIL PROTECTED]> wrote:
> Did you find a sollution? I need to get the offset of a member of a struct
> so I can port a .h to a .di but dmd complains that the member doesn't exist
> on the struct. I dont think anyone has ever tried the code at:
> http://www.d
I tried 1.036 and had the same problem. I'm using the offsetof and sizeof
in a few constants which I've defined at the beginning of the file so I
tried moving to the end of the file and it is no longer in error. I read
somewhere that you don't have to forward declare everythin
On Fri, Nov 7, 2008 at 11:38 PM, Tim M <[EMAIL PROTECTED]> wrote:
> I tried 1.036 and had the same problem. I'm using the offsetof and sizeof in
> a few constants which I've defined at the beginning of the file so I tried
> moving to the end of the file and it is n
On 09/07/2012 10:31 AM, Ellery Newcomer wrote:
I have a struct buffer, and I want to print out its members' offsetof.
This:
foreach(i,_t; buffer.tupleof) {
writefln("%s@: %s", _t.stringof, _t.offsetof);
}
complains
Error: undefined identifier 'offs
On Friday, 7 September 2012 at 17:32:43 UTC, Ellery Newcomer
wrote:
On 09/07/2012 10:31 AM, Ellery Newcomer wrote:
I have a struct buffer, and I want to print out its members'
offsetof.
This:
foreach(i,_t; buffer.tupleof) {
writefln("%s@: %s", _t.string
Error: this for x needs to be type TestStruct not type
main.TestClass
Is this a known bug? How can I work around this issue in order to
use offsetof from a class function that is not static?
Thanks
This also works fine:
void test3()
{
TestStruct dummy;
writeln(dummy.x.offsetof);
}
This works for me if I add parentheses to the line where you get
the error like this:
writeln(TestStruct().x.offsetof);//bug here
The error you were getting is not related to offsetof. The
problem seems to be that if you write TestStruct.x inside a
non-static method, the compiler thinks you
n bug? How can I work around this issue in order to use
offsetof from a class function that is not static?
Thanks
I don't know whether that is a bug but the class page at
http://dlang.org/class.html
says ".offsetof can only be applied to expressions which produce the
type of the fi
Thanks jerro and Ali, I see your points. I thought offsetof was
like C/C++'s sizeof... Guess while taking a crash course at a new
language I will often bump into issues because I haven't read a
specific doc.
On 2012-11-26 05:49, Geancarlo wrote:
Thanks jerro and Ali, I see your points. I thought offsetof was like
C/C++'s sizeof... Guess while taking a crash course at a new language I
will often bump into issues because I haven't read a specific doc.
You do have .sizeof in D as well.
On 2012-11-26 05:03, jerro wrote:
This works for me if I add parentheses to the line where you get the
error like this:
writeln(TestStruct().x.offsetof);//bug here
This will create an instance of TestStruct.
--
/Jacob Carlborg
On Monday, 26 November 2012 at 03:23:42 UTC, Geancarlo wrote:
Hello, I'm using DMD32 D Compiler v2.060 for on Windows.
writeln(TestStruct.x.offsetof);//bug here
This works without creating your own instance:
writeln(TestStruct.init.x.offsetof);
Thanks
Dan
Cannot get the offset of static members of a struct
struct X
{
__gshared public:
int x;
}
X.x.offsetof < invalid.
We can clearly get a pointer to the static struct X since &X.x is
effectively the address of X(regardless nomenclature and
terminology issues in D trying to hide this
Cannot get the offset of static members of a struct
struct X
{
__gshared public:
int x;
}
X.x.offsetof < invalid.
We can clearly get a pointer to the static struct X since &X.x is
effectively the address of X(regardless nomenclature and
terminology issues in D trying to hide this
On Monday, 10 July 2017 at 20:01:39 UTC, FoxyBrown wrote:
Cannot get the offset of static members of a struct
That's because static members do not have an offset. They are not
part of the struct in memory, just in name.
We can clearly get a pointer to the static struct X
There's barely an
On Monday, 10 July 2017 at 20:13:46 UTC, Adam D. Ruppe wrote:
On Monday, 10 July 2017 at 20:01:39 UTC, FoxyBrown wrote:
Cannot get the offset of static members of a struct
That's because static members do not have an offset. They are
not part of the struct in memory, just in name.
We can c
On 07/10/2017 02:14 PM, FoxyBrown wrote:
> On Monday, 10 July 2017 at 20:13:46 UTC, Adam D. Ruppe wrote:
>> On Monday, 10 July 2017 at 20:01:39 UTC, FoxyBrown wrote:
>>> Cannot get the offset of static members of a struct
>>
>> That's because static members do not have an offset. They are not part
On 7/11/2017 6:14 AM, FoxyBrown wrote:
On Monday, 10 July 2017 at 20:13:46 UTC, Adam D. Ruppe wrote:
No, it isn't. Static members are stored in an entirely different place
than non-static members. They are really just global variables in
memory with their in-source name being nested somewhere
On 07/10/2017 11:14 PM, FoxyBrown wrote:
auto GetStaticAddress(T)()
{
mixin("auto p = cast(T*)&T."~__traits(allMembers, T)[0]~";");
return p;
}
Returns the address of a struct's static members.
No, it returns the address of T's first member.
It's pretty obvious, the compiler seems
I am receiving this error:
```
Error: no property `offsetof` for type `char*`
```
from this snippet:
```d
import core.sys.windows.setupapi;
void main() {
SP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetail;
uint Offset = DeviceInterfaceDetail.DevicePath.offsetof;
}
```
You may
It's a method returning a `CHAR*` - `_DevicePath` is the actual
member. I guess it's a dynamically sized struct, which cannot be
mapped directly to D, hence this representation.
Thank you, that seems to have resolved the issue, though I wish
these sorts of problems would stop cropping up, they are souring
the experience with the language.
On 8/19/22 9:49 AM, MyNameHere wrote:
Thank you, that seems to have resolved the issue, though I wish these
sorts of problems would stop cropping up, they are souring the
experience with the language.
Most likely that "member" is a macro in C. D doesn't have macros, so it
uses properties.
T
On Friday, 19 August 2022 at 14:22:04 UTC, Steven Schveighoffer
wrote:
On 8/19/22 9:49 AM, MyNameHere wrote:
Thank you, that seems to have resolved the issue, though I
wish these sorts of problems would stop cropping up, they are
souring the experience with the language.
Most likely that "mem
the 'dynamic array' (as the array decays to a pointer in C
too), so no need to fiddle with `.offsetof` and computing the
pointer manually.
On Friday, 19 August 2022 at 14:30:50 UTC, kinke wrote:
Oh and `DevicePath()` is a convenience member returning a
pointer to the 'dynamic array' (as the array decays to a
pointer in C too), so no need to fiddle with `.offsetof` and
computing the pointer manually.
I am using `
On 8/19/22 12:36 PM, MyNameHere wrote:
On Friday, 19 August 2022 at 14:30:50 UTC, kinke wrote:
Oh and `DevicePath()` is a convenience member returning a pointer to
the 'dynamic array' (as the array decays to a pointer in C too), so no
need to fiddle with `.offsetof` and computing t
On Friday, 19 August 2022 at 16:36:24 UTC, MyNameHere wrote:
On Friday, 19 August 2022 at 14:30:50 UTC, kinke wrote:
Oh and `DevicePath()` is a convenience member returning a
pointer to the 'dynamic array' (as the array decays to a
pointer in C too), so no need to fiddle with `.off
31 matches
Mail list logo