Click here to Skip to main content
15,915,501 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: can anybody help me in solving my problem with connecting to the database Pin
chandu0048-Oct-07 0:59
chandu0048-Oct-07 0:59 
AnswerRe: can anybody help me in solving my problem with connecting to the database Pin
Hamid_RT8-Oct-07 1:08
Hamid_RT8-Oct-07 1:08 
AnswerRe: can anybody help me in solving my problem with connecting to the database Pin
David Crow8-Oct-07 3:47
David Crow8-Oct-07 3:47 
Questionunion and struct Pin
KASR17-Oct-07 23:47
KASR17-Oct-07 23:47 
AnswerRe: union and struct Pin
Maxwell Chen8-Oct-07 0:11
Maxwell Chen8-Oct-07 0:11 
AnswerRe: union and struct Pin
Hamid_RT8-Oct-07 0:24
Hamid_RT8-Oct-07 0:24 
GeneralRe: union and struct Pin
KASR18-Oct-07 0:28
KASR18-Oct-07 0:28 
GeneralRe: union and struct Pin
Hamid_RT8-Oct-07 0:45
Hamid_RT8-Oct-07 0:45 
GeneralRe: union and struct Pin
KASR18-Oct-07 0:55
KASR18-Oct-07 0:55 
AnswerRe: union and struct Pin
Maxwell Chen8-Oct-07 0:34
Maxwell Chen8-Oct-07 0:34 
Answerlets continue the same discussion Pin
chandu0048-Oct-07 1:03
chandu0048-Oct-07 1:03 
GeneralRe: lets continue the same discussion Pin
Hamid_RT8-Oct-07 1:10
Hamid_RT8-Oct-07 1:10 
GeneralRe: lets continue the same discussion Pin
chandu0048-Oct-07 1:14
chandu0048-Oct-07 1:14 
GeneralRe: lets continue the same discussion Pin
Hamid_RT8-Oct-07 1:22
Hamid_RT8-Oct-07 1:22 
GeneralRe: lets continue the same discussion Pin
JudyL_MD8-Oct-07 2:27
JudyL_MD8-Oct-07 2:27 
chandu004 wrote:
some realtime example do demonstrate the use of union.


from wdm.h (a driver include file):

typedef struct _PCI_COMMON_HEADER {
    USHORT  VendorID;                   // (ro)
    USHORT  DeviceID;                   // (ro)
    USHORT  Command;                    // Device control
    USHORT  Status;
    UCHAR   RevisionID;                 // (ro)
    UCHAR   ProgIf;                     // (ro)
    UCHAR   SubClass;                   // (ro)
    UCHAR   BaseClass;                  // (ro)
    UCHAR   CacheLineSize;              // (ro+)
    UCHAR   LatencyTimer;               // (ro+)
    UCHAR   HeaderType;                 // (ro)
    UCHAR   BIST;                       // Built in self test

    union {
        struct _PCI_HEADER_TYPE_0 {
            ULONG   BaseAddresses[PCI_TYPE0_ADDRESSES];
            ULONG   CIS;
            USHORT  SubVendorID;
            USHORT  SubSystemID;
            ULONG   ROMBaseAddress;
            UCHAR   CapabilitiesPtr;
            UCHAR   Reserved1[3];
            ULONG   Reserved2;
            UCHAR   InterruptLine;      //
            UCHAR   InterruptPin;       // (ro)
            UCHAR   MinimumGrant;       // (ro)
            UCHAR   MaximumLatency;     // (ro)
        } type0;

        // PCI to PCI Bridge
        struct _PCI_HEADER_TYPE_1 {
            ULONG   BaseAddresses[PCI_TYPE1_ADDRESSES];
            UCHAR   PrimaryBus;
            UCHAR   SecondaryBus;
            UCHAR   SubordinateBus;
            UCHAR   SecondaryLatency;
            UCHAR   IOBase;
            UCHAR   IOLimit;
            USHORT  SecondaryStatus;
            USHORT  MemoryBase;
            USHORT  MemoryLimit;
            USHORT  PrefetchBase;
            USHORT  PrefetchLimit;
            ULONG   PrefetchBaseUpper32;
            ULONG   PrefetchLimitUpper32;
            USHORT  IOBaseUpper16;
            USHORT  IOLimitUpper16;
            UCHAR   CapabilitiesPtr;
            UCHAR   Reserved1[3];
            ULONG   ROMBaseAddress;
            UCHAR   InterruptLine;
            UCHAR   InterruptPin;
            USHORT  BridgeControl;
        } type1;

        // PCI to CARDBUS Bridge
        struct _PCI_HEADER_TYPE_2 {
            ULONG   SocketRegistersBaseAddress;
            UCHAR   CapabilitiesPtr;
            UCHAR   Reserved;
            USHORT  SecondaryStatus;
            UCHAR   PrimaryBus;
            UCHAR   SecondaryBus;
            UCHAR   SubordinateBus;
            UCHAR   SecondaryLatency;
            struct  {
                ULONG   Base;
                ULONG   Limit;
            }       Range[PCI_TYPE2_ADDRESSES-1];
            UCHAR   InterruptLine;
            UCHAR   InterruptPin;
            USHORT  BridgeControl;
        } type2;
    } u;
} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;

Depending on the value in HeaderType, one of the three unions (type0, type1 or type2) is the "correct" one to be used.
GeneralRe: lets continue the same discussion Pin
toxcct8-Oct-07 3:11
toxcct8-Oct-07 3:11 
GeneralRe: lets continue the same discussion Pin
Nemanja Trifunovic8-Oct-07 2:57
Nemanja Trifunovic8-Oct-07 2:57 
AnswerRe: union and struct Pin
ShilpiP8-Oct-07 1:52
ShilpiP8-Oct-07 1:52 
Questionpointers Pin
KASR17-Oct-07 23:46
KASR17-Oct-07 23:46 
AnswerRe: pointers Pin
Maxwell Chen8-Oct-07 0:12
Maxwell Chen8-Oct-07 0:12 
AnswerRe: pointers Pin
Hamid_RT8-Oct-07 0:31
Hamid_RT8-Oct-07 0:31 
Questionabout thread memory space Pin
DSPCottage7-Oct-07 22:22
DSPCottage7-Oct-07 22:22 
AnswerRe: about thread memory space Pin
Matthew Faithfull7-Oct-07 23:03
Matthew Faithfull7-Oct-07 23:03 
GeneralRe: about thread memory space Pin
DSPCottage8-Oct-07 1:35
DSPCottage8-Oct-07 1:35 
AnswerRe: about thread memory space Pin
chandu0048-Oct-07 2:00
chandu0048-Oct-07 2:00 

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.