What is the D equivalent to the C __attribute__((packed))

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
brentS
Posts: 16
Joined: Sat Jun 27, 2009 5:41 pm

What is the D equivalent to the C __attribute__((packed))

Post by brentS »

How would you tell the D compiler you want a struct '__attribute__((packed))' ?
User avatar
Zenith
Member
Member
Posts: 224
Joined: Tue Apr 10, 2007 4:42 pm

Re: What is the D equivalent to the C __attribute__((packed))

Post by Zenith »

Glad to see someone else is interested in D, though I'd advise someone to get really comfortable with the language before starting OSDev with it. :wink:

Anyway, alignment is done using the align() attribute. For an entire struct to have packed alignment, you'd do align(1) struct {...}. More info can be found at the D specification site, specifically here.

Hope this helps!
"Sufficiently advanced stupidity is indistinguishable from malice."
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: What is the D equivalent to the C __attribute__((packed))

Post by Solar »

Zenith wrote:I'd advise someone to get really comfortable with the language before starting OSDev with it. :wink:
Very true, regardless of the language.
Every good solution is obvious once you've found it.
brentS
Posts: 16
Joined: Sat Jun 27, 2009 5:41 pm

Re: What is the D equivalent to the C __attribute__((packed))

Post by brentS »

Thanks. And yeh I know lol I should have played around with D a little more before jumping into a kernel but...temptation gets you hha.
Post Reply