Highorder bits of bit field go to bit bucket

Highorder bits of bit field go to bit bucket

Post by Cary Jamiso » Wed, 09 Jul 2003 04:36:59



The following code produces different results when compiled as a Windows
executable vs a NetWare .nlm.

#include <iostream>
#include <string.h>

void main()
{
 struct BFTest {
   unsigned char f1 : 1;
   unsigned char f2 : 3;
   unsigned char f3 : 4;

   unsigned short f4 : 1;
   unsigned short f5 : 13;
   unsigned short f6 : 2;
 };

 BFTest bf;
 memset(&bf, 0, sizeof(bf));

 bf.f5 = 0x1234;
 std::cout << "f5 = " << std::hex << bf.f5 << std::endl;

Quote:}

On Windows the correct results (f5 = 1234) is produced.  On NetWare the
result is (f5 = 34).

The correct results are also produced by VC and GCC.

Am I missing something obvious, like a compile-time flag?  Or is this a bug
in the NetWare compiler?

I'm using CodeWarrior 8.3.

Thanks,
Cary Jamison

 
 
 

1. PIC How to: 24 Bit / 16 bit = 16 bit (division routine on a 8 bit PIC )

All Help appreciated

----------------------------------------------------,
 ___  _     _     ___                               |
|   \(_)_ _| |__ |   \ _  _ _ __ _ _ ___            |
| |) | | '_| / / | |) | || | '_ \ '_/ -_)           |
|___/|_|_| |_\_\ |___/ \_,_| .__/_| \___|           |
                           |_|                      |
To Reply to this message remove _ in my email adres.|
Visit my LX page: www.ping.be/d_d_u (remove all _ ) |
----------------------------------------------------'

2. Problem in migrating from Oracle 8i to 9i

3. bit field operations on 16 bit word memory

4. Setting Maximum number of SSH connections?

5. How to set up bits in bit string field?

6. repeating numbered equations

7. Is 24-bit color and 8-bit grayscale enough?

8. Please help with copyright date: Guadalcanal Campaign - SSI

9. 24 bit or 48 bit

10. 8-bit vs 12-bit scanning

11. Scanning B/W negs in Vuescan as 48 bit RGB or 64 bit RGBI?

12. VueScan and 36 bits on 24-bit-scanners

13. 8 bit or 12 bit