|
struct S2
{
WORD w0;
};
struct S6A
{
WORD w0;
DWORD dw0;
};
struct S6B
{
WORD w0,w1;
WORD w2;
};
struct S10A
{
WORD w0;
DWORD dw0;
DWORD dw1;
};
struct S10B
{
WORD w0,w1,w2,w3,w4;
};
if use sizeof() to calculate size of structs above, they are
2, 8, 6, 12, 10 respectively (tested on windows OS - not DOS).
align? why in this way?
includeh10
|
|
|
|
|
Structs/classes are padded internally to make members aligned properly (most common CPUs other than x86 will fault on unaligned memory access). So in the case of:
struct S6A
{
WORD w0;
DWORD dw0;
}; if dw0 came right after w0 in memory, it would not lie on a DWORD boundary, so 2 bytes of padding are added to make dw0 aligned. This behavior can be changed with #pragma pack .
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
By default struct s are aligned on 8-byte boundaries. If you are having alignment problems, check out the #pramga pack directive, or the /Zp compiler switch.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DWORDS can only appear at offsets which are a multiple of four. (sizeof(DWORD))
Compilers are required to lay out a structures members in the same order as they are declared.
Put these two together... the compiler must insert padding.
|
|
|
|
|
struct S2
{
WORD w0;
};
why sizeof(S2) is 2, not 4?
includeh10
|
|
|
|
|
because there's "nothing" after, is that a good answer ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Why do you want to know?
The compiler can do whatever it wants. Your particular compiler has choosen to do it this way. Unless you have told the compiler to do otherwise the compiler is allowed to do anything it wants.
In most cases this question is invalid - you do not need to know! IF you have an exception (they do exist, don't get me wrong), beware that the answer will change when anything else changes. Not just the CPU or compiler, but sometimes different compiler options will cause different things to happen!
|
|
|
|
|
How can i add a splash screen in mfc
Learner always
|
|
|
|
|
Hi,
Click on "Project" in the main menu bar. Select Add To Project->Components and Controls. Select Visual C++ Components from the Components and Controls Gallery Dialog box and click on Splash Screen and finally click on "Insert" button. Sit back and relax, rest is done by MFC for you. You just need to design the bitmap for ur Splash Screen.
Vikram Kashyap
"You will never fail until you stop trying"
|
|
|
|
|
How to add in .net .What if my application is dialog.
Learner always
|
|
|
|
|
I am creating a chat application .I have used a rich textbox for message writing.
I want to add emotions (small pictures)like in yahoo or "MSN" using toolbar and shotrcuts such as " " etc.
Can you help me.
Learner always
|
|
|
|
|
Hi all,
i use CWebBrowser2 (activeX control) on a dialog to display a web page.
the control shows Vertical scrollbar always, I want to hide the Vertical scrollbar because the web page just includes a small image - it will be much nicer if no vertical scrollbar.
I tried ctrl.ShowScrollbar(SB_VERT,0) and more, anyway the bar is there - i can't hide it.
can u help?
thx
includeh10
|
|
|
|
|
You can put this in the page itself:
<body scroll=no>
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
I think you need to set this in the HTML code itself. ( I just can't recall exacly what is the tag property ... )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
thx for u 2,
the tag works great!
I spent for one hour last night on this without any result!
cheers
includeh10
|
|
|
|
|
i'd like to get bitmap bits from an image.
I got the image 30X30, and i want to get the byte pointer to the one dimensional array of
30*30*24 where 24 is number of bits. How to make it?
I tried to use CImage, where i use the method GetBits(), but i got only the first line of
the picture - am i doing something wrong???
|
|
|
|
|
Hi,
I have a dll project but I no longer want to send the dll to the customer. Instead I want to send a lib file that the customer can link to in their projects (instead of loading the dll as they do today).
1. is there a way to convert the dll project into a static library?
if so how?
2. If not, I presume I have to create a new static library project from
scratch using New Project w32 static lib. Right?
3. If I have to create a new static lib proj, how do I "export" the functions
from the projects so they are available for the customer that will link the lib?
Thanks!!!
|
|
|
|
|
ackabacka wrote:
3. If I have to create a new static lib proj, how do I "export" the functions
from the projects so they are available for the customer that will link the lib?
You don't have to do anything. The LIB is essentially like an OBJ file when it comes to linking, the LIB has the compiled version of your code, and the linker will search it for functions that your client calls.
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
Michael Dunn wrote:
You don't have to do anything. The LIB is essentially like an OBJ file when it comes to linking, the LIB has the compiled version of your code, and the linker will search it for functions that your client calls.
OK thanks.
I've now created a new static library project and (re) created all functions, as it didn't seem possible to change any setting for the dll project to have it compile a static library (or is it?).
It works fine for me, but now I wonder, who can use this library?
It doesn't use MFC.
Sure, it will only run on intel compatible computers running Windows but what else is required.
Of course another VC++ 6 developer could use it (as it's compiled under VC++ v6), but what if the developer is using VC++ .NET environment, with or without managed C++?
What if the developer is using another c++ compiler (Intel, Borland etc)?
Anyone?
|
|
|
|
|
When you compile the code as C++, the LIB can only be used by compilers that understand the VC name decoration scheme. VC 6 and 7.x do so, as does the Intel compiler. There may be others as well, but those are the only ones I've used.
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
OK, thanks.
Actually no classes are availble from "outside".
The Lib has a static class (not a class with static functions but a static implemented class),
and only plain functions (that calls member functions of the static class) are available from outside (which prototypes are declared in the .h file that I send to the customer).
Does this make it possible to use it from even more compilers?
If not, is there perhaps a way to mark these functions as "C" functions?
Thanks!
|
|
|
|
|
Is there a way to put a menu in a dialog box in Visual C++.net?
|
|
|
|
|
I assume you mean in Visual C++.
Open the dialog in Resource View.
Go to Properties and find the Menu item (in Misc category).
Type or select the ID of the menu you want to use (you did create the menu first, didn't you?)
You won't see the menu appear in Resource View but it will work when you run the app.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
I appreciate you answer. I am new to Visual C++.net. I was able to figure out how to add the menu. Thanks for the help !
Chris
|
|
|
|
|
I want to print an Enhanced Metafile. This file is generated and printed by using GDI+ (Graphics and Metafile objects)
What kind of Device Context do I have to use while generating this metafile, to be independent from the printer device it will be printed out later on?
When I use a screen Device Context while generating this metafile and print it, the dimensions of the printed shapes are not OK !
|
|
|
|