Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / January 2004



Tip: Looking for answers? Try searching our database.

CWP9 Mach Bit Field Bug

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Dolinar - 15 Jan 2004 02:13 GMT
I'm having problems moving a bunch of legacy code to Mach and CWP9.
When you have 68k alignment turned on the following returns 8 with
Mach, but returns 6 with PEF:

#include <iostream>

typedef unsigned long ulong;

struct BookREC {
   
    short        bmanLocks;

    ulong        field1:3;
    ulong        field2:6;
    ulong        field3:2;

    ulong        field4:1;
    ulong        field5:1;
    ulong        field6:8;
    ulong        field7:1;
    ulong        field8:1;
    ulong        field9:7;
    ulong        field10:1;
    ulong        field11:1;
};

int main()
{
    using namespace std;
   
    cout << sizeof(BookREC) << endl;
   
    return 0;
}

Has anyone else ran across this?  Any ideas on how to get around this?
We probably have thousands of structs that use bit fields with no
easy way to find the ones that have problems.  We were planning on
finally upgrading from CWP8 to CWP9, but this is a show stopper.  This
works fine in CWP8 Update 3.

Thanks,
Bill
MW Ron - 15 Jan 2004 14:30 GMT
>I'm having problems moving a bunch of legacy code to Mach and CWP9.
>When you have 68k alignment turned on the following returns 8 with
[quoted text clipped - 36 lines]
>finally upgrading from CWP8 to CWP9, but this is a show stopper.  This
>works fine in CWP8 Update 3.

I see this too,  let me check with the PowerPC engineers.

Ron

Signature

Metrowerks, maker of CodeWarrior   -  "Software Starts Here"  
Ron Liechty - MWRon@metrowerks.com - <http://www.metrowerks.com>

MW Ron - 15 Jan 2004 17:39 GMT
We have a solution

#pragma old_style_bitfields on

I don't know why this wasn't documented in the release notes.

I tried your example with 68k alignment and it worked

Ron

>I'm having problems moving a bunch of legacy code to Mach and CWP9.
>When you have 68k alignment turned on the following returns 8 with
[quoted text clipped - 39 lines]
>Thanks,
>Bill

Signature

Metrowerks, maker of CodeWarrior   -  "Software Starts Here"  
Ron Liechty - MWRon@metrowerks.com - <http://www.metrowerks.com>

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.