8 bytes vs. 4 bytes Struct member alignment

Hi,

I have an VC++ application which I have to compile on **4 bytes Struct
member alignment** in order to read correctly a binary file and pass
the data to a complex structure.
(As default, VC++ Struct member alignment compilation is 8 bytes. But
if I compile as 8 bytes, the element of structure are not correctly
interpreted).
Part of this project (compiled as 4 bytes) should be integrated into a
master application compiled as 8 bytes as default.
Which is the way to deal with this 4 bytes and 8 bytes simultaneous?
(I would prefer NOT to change the structure members and I would like
to keep the same binary file format).
One solution could be to create a windows library compiled as 4 bytes
in which I read the binary file and pass the values to the structure.
And then include this library into a 8 bytes project (as default) and
pass the structure from the library to the master application.
Is it working in this way? Any others solutions are appreciated.


Thank you,
Chris
0
5/13/2004 6:42:37 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
725 Views

Similar Articles

[PageSpeed] 56

Found the way:
use:
#pragma pack(4) //for 4 bytes alignment

On Thu, 13 May 2004 14:42:37 -0400, Christian
<cristian_marinescu@sympatico.ca> wrote:

>Hi,
>
>I have an VC++ application which I have to compile on **4 bytes Struct
>member alignment** in order to read correctly a binary file and pass
>the data to a complex structure.
>(As default, VC++ Struct member alignment compilation is 8 bytes. But
>if I compile as 8 bytes, the element of structure are not correctly
>interpreted).
>Part of this project (compiled as 4 bytes) should be integrated into a
>master application compiled as 8 bytes as default.
>Which is the way to deal with this 4 bytes and 8 bytes simultaneous?
>(I would prefer NOT to change the structure members and I would like
>to keep the same binary file format).
>One solution could be to create a windows library compiled as 4 bytes
>in which I read the binary file and pass the values to the structure.
>And then include this library into a 8 bytes project (as default) and
>pass the structure from the library to the master application.
>Is it working in this way? Any others solutions are appreciated.
>
>
>Thank you,
>Chris

0
5/14/2004 6:54:59 PM
#pragma pack(push)
#pragma pack(8)
typedef struct {
}...'

#pragma pack(pop)

Forget any other settings. Just control the alignment of the structure you need to control
the alignment to.

If the syntax is not exactly as I described above, I'm close. Read the docs on #pragma
pack.
				joe

On Thu, 13 May 2004 14:42:37 -0400, Christian <cristian_marinescu@sympatico.ca> wrote:

>Hi,
>
>I have an VC++ application which I have to compile on **4 bytes Struct
>member alignment** in order to read correctly a binary file and pass
>the data to a complex structure.
>(As default, VC++ Struct member alignment compilation is 8 bytes. But
>if I compile as 8 bytes, the element of structure are not correctly
>interpreted).
>Part of this project (compiled as 4 bytes) should be integrated into a
>master application compiled as 8 bytes as default.
>Which is the way to deal with this 4 bytes and 8 bytes simultaneous?
>(I would prefer NOT to change the structure members and I would like
>to keep the same binary file format).
>One solution could be to create a windows library compiled as 4 bytes
>in which I read the binary file and pass the values to the structure.
>And then include this library into a 8 bytes project (as default) and
>pass the structure from the library to the master application.
>Is it working in this way? Any others solutions are appreciated.
>
>
>Thank you,
>Chris

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
5/14/2004 10:45:54 PM
Reply:

Similar Artilces:

error message #8
How do I install Money 2004 and set it up to use Norton Utilities? In microsoft.public.money, bkoch wrote: >How do I install Money 2004 and set it up to use Norton >Utilities? Try it? If no go, read various opinions and experiences that have been posted: http://groups.google.com/groups?as_q=&num=50&as_scoring=d&hl=en&ie=UTF-8&oe=UTF-8&btnG=Google+Search&as_epq=&as_oq=nav+norton&as_eq=google&as_ugroup=microsoft.public.money&as_usubject=&as_uauthors=&as_umsgid=&lr=&as_drrb=q&as_qdr=&as_mind=12&as_minm=5&as_mi...

Money 4.0 backup file to Money 2004
I can't seem to get the old backup file to convert to Money 2004... it keeps telling me that it was created by an incompatible version. Does anyone know of a workaround? Should I see about getting an intermediate version and working from that? Thanks for any help! Gord --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.687 / Virus Database: 448 - Release Date: 16/05/2004 In microsoft.public.money, Gord Spence wrote: >I can't seem to get the old backup file to convert to Money 2004... it keeps >telling me th...

great palins 8.0 us payroll
can i see a traning demo session on us payroll 8.0 ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGroups/dgbrowser/en-us/default.mspx?mid=64dd06be-2f56-4c41-91cc-e1c977be182a&dg=microsoft.public.greatplains ...

Member Server to Domain Controller
Hi How do I promote a member server running Windows 2003 Server SP2 and Certificate Services to a domain controller. Regards Use the system command dcpromo Check out the link below http://www.petri.co.il/how_to_install_active_directory_on_windows_2003.htm -- Paul Bergson MVP - Directory Services MCITP - Enterprise Administrator MCTS, MCT, MCSE, MCSA, MCP, Security +, BS CSci 2008, Vista, 2003, 2000 (Early Achiever), NT4 Microsoft's Thrive IT Pro of the Month - June 2009 http://www.pbbergs.com Please no e-mails, any questions should be posted in the NewGroups. ...

Spell Check option for crm 4.0
Hi Could you guys share your thoughts on what are the different options available for spell checking in CRM 4.0 Thank You Kind Regards Get a spellchecker for your browser. http://www.ie7pro.com/ includes spell checking amongst lots of other great features. Other addins for IE exist for this too, most produce red-squiggle underlining similar to MS Word. Make sure they have dictionaries to support your language and region (eg UK vs US English) Adam On 02/06/2010 15:16, ~Jij wrote: > Hi > Could you guys share your thoughts on what are the different options > available for spell ...

CRM 4 cannot activate Language pack activation after upgrade
Hi folks!! I have an important migration to work on, basically driven because of the need of the language pack, but after upgrading from 3 to 4, I cannot activate the language pack. They install without error, but no way to activate them. I am almosr certain it may be related to the fact that many of the different entities may have found themsleves modified and some "default" field removed (as some other post mentionned), but just in case, I am posting this request for help. I am goign to embark in trying to work around this by doing (in lab of course) many steps to see if it will...

Hyperlink #8
Does anyone know why I cant insert a hyperlink in a shared worksheet? Hi this is a restriction of shared workbooks. Only hyperlinks inserted BEFORE sharing the workbook work, no chance to insert new ones -- Regards Frank Kabel Frankfurt, Germany Nick wrote: > Does anyone know why I cant insert a hyperlink in a shared > worksheet? ...

Reading and writing UTF-8 files
I have to do some simple text editing to large-ish (2 Mbyte) html files generated by Word. They are, I believe, in UTF-8. It is the !%^&* problem where single apostrophes become sequences of funny characters, some spaces are shown as unprintable characters, etc. The following code just reads and writes a file, and shows the problem. It applies whether I use a String or a StringBuilder, and whether or not I explicitly force UTF-8 encoding. Can somebody just tell me basically how to copy an html file by reading it in and then writing it out, which is all the following meth...

How to transmit byte on LPT port ??
I want to transmit a byte on LPT port, I use _outp(0x378,ch). - I run on Win98 that is OK. - I run on Win2K system give error message. I want that program can run on Win98/WinXP/Win2K. Anyone can help me ! thank you very much ! outp only worked because MS_DOS (which was thinly disguised to look like an operating system) had no protection. This cannot function on a real operating system, because I/O instructions are privileged. If all you are doing is writing bytes out, any system can allow you to CreateFile(_T("LPT:") ... ) and it will work fine (I know this works, we have a legacy ...

Marketing Lists, Exporting Marketing List Members to Excel
Hi all, I hope that somebody can help me out here. We've just discovered what we think is a bug with the exports to Excel. When we try to export the all of the members of a Marketing List (16320 in total), only 3000 are exported in Excel. The web server is setup to allow 30 000 lines per Excel export, and when we modify that to 40 000 and try to export the members we get 4000 lines... From that test it looks like there's a bug that reduces the Excel export to 10% of the number of Marketing List Members. If I use the Manage Members function and an Advanced Find I can get almost ...

XP vs Vista
Curruntly I own one station(rms2.0) window xp and SQL 2000 special addition because my data already cross 4gb. Now I am planing to ad second station in my store. Can I run one station xp and new one Vista or I have to have both window xp. Do I need to upgrade sql server. I need more help before I buy second station. Harjit, I got for a test an XP (virtual) and a Vista system with R.M.S. SO. With a database on a SQL2000 instance on the XP system. The Vista and XP system worked both fine and fast, so that is no problem. The only thing that could be a problem is drivers for your hardwa...

problem installing CRM 4
Hi all, I have a problem installing CRM 4. After installing the VC++ runtime library I click Next and then this error appears and drops the instalation. Did anyone meet the same error. The type initializer for 'Microsoft.CRM.LocatorService' threw an exception The type initializer for 'Microsoft.CRM.ServerLocatorService' threw an exception Input string was not in the correct form. can you see the log file on this <systemdrive>:\Documents and Settings\<User>\Application Data\Microsoft \MSCRM\Logs\ -- Regards, MS CRM Certified Professional http://microsof...

Percentages #8
Hi there, hope somebody out there in cyberworld can help me with the following probably easy to answer post. I have a number in box A1 lets say 100. This number is what I have dealt with over the month. In box B1 I have 10 and in box C1 I have 10. The numbers in B1 and C1 are figures within the 100 that I have missed for the month. How do I calculate out of 100% what I have achieved. I know how to calculate what percentage I have missed, i.e =sum(B1:C1)/A1*100 = 20%. ACHIEVED A1 = 100 MISSED B1 = 10 + C1 = 10 PERCENTAGE ACHIEVED = ? Thanks in advance for any help given. Terry ...

MS Outlook vs Oulook Express
For some reason, my default program is Express. I went into properties an clicked on the pull down to select MS Outlook as my default, but Express still comes up when accessed through Earhtlink. >-----Original Message----- >For some reason, my default program is Express. I went >into properties an clicked on the pull down to select MS >Outlook as my default, but Express still comes up when >accessed through Earhtlink. >. >I'm having exactly the same problem even though I have set all my Outlook and control panel settings to default to Outlook. Did you get an...

IE 8 Parsing issues?
Hello, since a few month we're having strange requests in our web server logs. Example: 2010-01-27 18:00:35 W3SVC183691552 194.183.128.104 GET /SysRes/GLOBALSkin/Ski/head><body+onload= - 80 - 194.183.153.12 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+5.1;+Trident/4.0) http://my.domain.at/ 200 0 3 21699 757 46 Sometimes embedded resources like Scripts or CSS files are not loaded correctly. The path to the external resources is broken by adding any HTML code snippet of the page which embeds the resources. It happens on different pages / applications on our serv...

Results of formula vs real numbers
HI. How do you change a formula to read the value as a result of a formula and not necessarily as a real number? Example: In G6, i have the following formula that gives me the hour of a time in F6 =IF(F6>0,MOD(F6-"1:00",1),"") F6 contains 00:30:08, The result is 23 In another cell, I am using this formula, but it doesnt recognize the 23. =SUMPRODUCT(--(B6:B58331="james"),--(G6:G58331="23")) The 23 is actually the HOUR of time so it isn't a whole number or real number persay. It is a rounded time to the hour. Yes, but it isn't a text ...

How do I convert pounds to stones eg 200 pounds is 14 stone 4 lb
I have a table of weights, in pounds. How do I convert them to stones and pounds in excel. I dont want to say 14.5 stomes, I want to say 14 stones 7 pounds. Thanks Hi, With pounds in a1 try this =INT(A1/14) & " Stones " & MOD(A1,14)&" Pounds" Mike "J" wrote: > I have a table of weights, in pounds. How do I convert them to stones and > pounds in excel. I dont want to say 14.5 stomes, I want to say 14 stones 7 > pounds. > Thanks Try this: =TRUNC(A1/14) & " STONES " & ROUND(SUM(11/14,-TRUNC(11/...

Business Management Error Move CRM 4.0 Database to Different Machi
Hi, I have backed up a CRM 4.0 _MSCRM and MSCRM_Config database from one machine and restored both on another machine ( Which had been useing a test database). After restoring both databases on the new host I used the Deployment Manger to import the restored database. After completing the import when I attempt to open CRM I get an error message saying " Business Management Error The user ID associated the current record is not valid" From the server where I'm logged an as Administrator On client PC I get the following. Server Error in '/...

PDC module in Great Plains 8
Hi i just wonder do we have a Post Dated Checks solution as a module in Great Plains 8 regards Nader How do you want it to work? "Nader Yousef" wrote: > Hi > > i just wonder do we have a Post Dated Checks solution as a module in Great > Plains 8 > > regards > Nader When a customer pays for his goods he pays the cashier a cash deposit which should be recorded as a CRV and the balance is to be payed by a Post Dated Checks with different due dates and the customer account is credited and debit the PDC account and when the check is deposited and acce...

Charting Data Series vs. Data Points?
If I am trying to chart a single row of data appearing in 600 columns, is this data in 600 data points, which is chartable, or is it 600 series, which is not chartable? I have divided the data between three worksheets due to worksheet limitations of 256 columns, but I have not been able to create a single chart line for data extending over the three worksheets. Tommy wrote on Tue, 29 Nov 2005 07:31:06 -0800: TZ> If I am trying to chart a single row of data appearing in TZ> 600 columns, is this data in 600 data points, which is TZ> chartable, or is it 600 series, which is no...

CRM 4: Quotedetail prices won't be synchronized
Hello, i have an problem synchronizing some data from the outlook client to the server. Situation: I use the oulook laptop client in offline mode. I create a new quote. From within the quote i am calling a application via a navigation bar link. From within this application i add a new manual quotedetail (write-in product) to the quote (it is saved allready) and set a price (all via the CRM WebServices) After this i can see the quotedetail in the write-in products list. Then in outlook i go online. After the sync is done, at the server i can see the new generated quote and also the added...

Labels #8
How do I import data from a data file to be printed onto labels in Microspft publisher. Hi Jlabels (Jlabels@discussions.microsoft.com), in the newsgroups you posted: || How do I import data from a data file to be printed onto labels in || Microspft publisher. Check out the following link: http://www.publishermvps.com/Default.aspx?tabid=92 -- Brian Kvalheim Microsoft Publisher MVP http://www.publishermvps.com ~pay it forward~ This posting is provided "AS IS" with no warranties, and confers no rights. ...

ByVal vs. ByRef 11-17-09
I guess I have fallen into the habit of generally passing values ByRef, unless I am certain that the method will never need to alter the value. Also I have never been quite sure what it means to pass a reference type ByVal. And I have never had a problem. Until this past weekend. This past weekend I was playing around with a TreeView representation of a directory and developed the code attached below. The code is very straightforward. A button click routine establishes the topmost node and then calls a recursive subroutine, Populate, to populate the rest of the tree. The ...

one domain
We have one domain (xyz.com) split over 4 sites. One site has an exchange 2000 server and the others use a traditional POP3 server. All sites download from an external POP3 server (1 mailbox per site). All sites use messagelabs as a smarthost. My problem is that the Exchange server wants to take full responsibility for the doman (xyz.com) so people in the exchange site cannot send emails to staff in the other three sites. The Exchange just reports that the user doesn't exist. Any suggestions? Thanks Interesting setup, that... And I'm not sure I can help but, for all intents an...

4 different axis in chart ?
Hello, for a particular analysis I would like to use all 4 axis with different label. Is that feasable, and if so, how can I tackle the task? Thank you in advance! Kind regards, H.G. Lamy H.G. Lamy - For an example of an XY (Scatter) chart with four axes titles, browse to www.MikeMiddleton.com, and download the "MultipleAxesScientificChart" workbook. It was created using Excel 2003 SP3. For chart-related questions, I suggest microsoft.public.excel.charting, and be sure to mention your version of Excel. - Mike http://www.MikeMiddleton.com &...