Click here to Skip to main content
15,915,611 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Displaying pictures on a web page from a folder Pin
Christian Graus29-Jan-07 22:59
protectorChristian Graus29-Jan-07 22:59 
QuestionCannot Uninstall Windows Services.... Pin
Draqonis29-Jan-07 10:00
Draqonis29-Jan-07 10:00 
AnswerRe: Cannot Uninstall Windows Services.... Pin
Vasudevan Deepak Kumar29-Jan-07 22:39
Vasudevan Deepak Kumar29-Jan-07 22:39 
QuestionHow doI scroll a webbrowser element via code? (c#) Pin
Jasmin Tabatabai29-Jan-07 3:24
Jasmin Tabatabai29-Jan-07 3:24 
AnswerRe: How doI scroll a webbrowser element via code? (c#) Pin
Thomas Stockwell3-Feb-07 16:04
professionalThomas Stockwell3-Feb-07 16:04 
QuestionCan any body tell me what are the steps and requisites to host an asp.net Pin
indian14328-Jan-07 19:35
indian14328-Jan-07 19:35 
AnswerRe: Can any body tell me what are the steps and requisites to host an asp.net Pin
Christian Graus28-Jan-07 19:44
protectorChristian Graus28-Jan-07 19:44 
GeneralRe: Can any body tell me what are the steps and requisites to host an asp.net Pin
indian14328-Jan-07 19:50
indian14328-Jan-07 19:50 
Questionhow to add crystal reports to vs .net 2005 standard edition Pin
MD1228-Jan-07 19:20
MD1228-Jan-07 19:20 
QuestionHow can I create a short cut key any button in .net Pin
indian14328-Jan-07 18:02
indian14328-Jan-07 18:02 
AnswerRe: How can I create a short cut key any button in .net Pin
Christian Graus28-Jan-07 18:42
protectorChristian Graus28-Jan-07 18:42 
GeneralRe: How can I create a short cut key any button in .net Pin
indian14328-Jan-07 19:37
indian14328-Jan-07 19:37 
GeneralRe: How can I create a short cut key any button in .net Pin
Christian Graus28-Jan-07 19:43
protectorChristian Graus28-Jan-07 19:43 
GeneralRe: How can I create a short cut key any button in .net Pin
indian14328-Jan-07 23:27
indian14328-Jan-07 23:27 
QuestionExtending large project to Unix (Mono) Pin
Libor Tinka28-Jan-07 10:36
Libor Tinka28-Jan-07 10:36 
QuestionDetecting AxWebBrowser scroll bars Pin
the red baron27-Jan-07 20:37
the red baron27-Jan-07 20:37 
Questioncan any body tell me the code for customizing the crystal reports Pin
indian14326-Jan-07 18:30
indian14326-Jan-07 18:30 
Question.Net Reactor Pin
Glen Harvy26-Jan-07 13:55
Glen Harvy26-Jan-07 13:55 
Questionwebcam preview Pin
sini8725-Jan-07 12:15
sini8725-Jan-07 12:15 
AnswerRe: webcam preview Pin
Christian Graus26-Jan-07 10:51
protectorChristian Graus26-Jan-07 10:51 
Questionmanaged c++.net: allocating the memory for an array of struct in a coherent memory area Pin
HUMPPAAA!25-Jan-07 9:43
HUMPPAAA!25-Jan-07 9:43 
AnswerRe: managed c++.net: allocating the memory for an array of struct in a coherent memory area Pin
Christian Graus26-Jan-07 10:51
protectorChristian Graus26-Jan-07 10:51 
GeneralRe: managed c++.net: allocating the memory for an array of struct in a coherent memory area Pin
HUMPPAAA!31-Jan-07 23:25
HUMPPAAA!31-Jan-07 23:25 
GeneralRe: managed c++.net: allocating the memory for an array of struct in a coherent memory area Pin
Luc Pattyn1-Feb-07 1:56
sitebuilderLuc Pattyn1-Feb-07 1:56 
There is nothing really strange about that, C (and C++ I guess) pads all its structs
so all elements are "naturally aligned" (to an adr that is a multiple of their size),
and aligns the entire struct to the size of the largest element, in your case 4B due to the DWORD/int.
The reason is the compiler can then emit code that manipulates 4B quantities without worrying
about alignment and/or achieving highest performance. (Some processors do not know how to
load a DWORD from an unaligned adr, others do but take more time to do it).

The net result is:

1)
if your struct's size is not a multiple of 4 but contains elements sized 4B, the struct will
act as if its size is a multiple of 4B (even when sizeof shows otherwise).

2)
if the elements in your struct are not "naturally aligned", the struct will be padded with
extra bytes to achieve the natural alignment (=each element gets aligned according to its size).
So
struct {
byte a; // offset 0
short b; // 1 ? not naturally aligned
byte c; // 3 ? OK
byte d; // 4 ? OK
long e; // 5 ? not naturally aligned
}

gets compiled as if it were:
struct {
byte a; // offset 0
byte bDummy;
short b; // offset 2
byte c; // offset 4
byte d; // offset 5
byte eDummy1;
byte eDummy2;
long e; // offset 8
}

The function you used was an old one, relying on a stride of 6B, so something special needed
to be done. In C (and C++ I guess) there are compiler switches and/or pragmas to disable
the alignment/padding. In C# your splitting the 4B into two 2B elements is probably the
best way to get what you needed.

Smile | :)








Luc Pattyn

QuestionDataBinding the UI control to the array element ? Pin
Patrick Sky24-Jan-07 20:57
Patrick Sky24-Jan-07 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.