Click here to Skip to main content
15,891,740 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to create client and server winsock in one project or use 2 winsock in one project? Pin
Moak25-Sep-10 23:52
Moak25-Sep-10 23:52 
GeneralRe: how to create client and server winsock in one project or use 2 winsock in one project? Pin
zhiyuan1625-Sep-10 23:57
zhiyuan1625-Sep-10 23:57 
GeneralRe: how to create client and server winsock in one project or use 2 winsock in one project? Pin
Moak26-Sep-10 0:59
Moak26-Sep-10 0:59 
GeneralRe: how to create client and server winsock in one project or use 2 winsock in one project? Pin
Richard MacCutchan26-Sep-10 1:04
mveRichard MacCutchan26-Sep-10 1:04 
QuestionMemory aligned bit fields Pin
Trevor Johansen24-Sep-10 21:34
Trevor Johansen24-Sep-10 21:34 
AnswerRe: Memory aligned bit fields Pin
Luc Pattyn24-Sep-10 23:02
sitebuilderLuc Pattyn24-Sep-10 23:02 
AnswerRe: Memory aligned bit fields Pin
Alain Rist24-Sep-10 23:53
Alain Rist24-Sep-10 23:53 
AnswerRe: Memory aligned bit fields Pin
Aescleal25-Sep-10 0:56
Aescleal25-Sep-10 0:56 
One cool thing about C++ is that you can keep doing hardware specific stuff in C style structures then add member functions to do the disgusting macro hackery and chicanery that you have to do to simplify your code. So for example if you've got a linear address for a 386 or later you can break it up in the same way as the processor does:

union linear_address_decoder
{
    struct decoded
    {
        unsigned page_directory_entry_ : 10;
        unsigned page_table_entry_ : 10;
        unsigned offset_ : 10;
    }
	decoded_;
    void *encoded_;

    linear_address_decoder( void *p ) : encoded_( p ) {}

    unsigned page_directory_entry() const
    {
        return decoded_.page_directory_entry_;
    }

    // ... ad nauseum...
};


Anyway it sounds like you want to go the other way (assembling a value to be stored in memory) but the principle is the same:

- Declare a union of the bunch of bit fields you're interested in and a primitive type that fills the memory location you want to read/write it from

- Add a constructor that takes the component bits and sticks them in the bit fields

- Have a recovery function to write the assembled value somewhere in memory.

Hope that helps - if I'm not being clear drop us a line and I'll try and clarify things.

Cheers,

Ash
AnswerRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 6:51
Trevor Johansen25-Sep-10 6:51 
AnswerRe: Memory aligned bit fields Pin
Aescleal25-Sep-10 7:26
Aescleal25-Sep-10 7:26 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 8:40
Trevor Johansen25-Sep-10 8:40 
AnswerRe: Memory aligned bit fields Pin
Aescleal25-Sep-10 10:07
Aescleal25-Sep-10 10:07 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 11:15
Trevor Johansen25-Sep-10 11:15 
AnswerRe: Memory aligned bit fields Pin
Luc Pattyn25-Sep-10 8:55
sitebuilderLuc Pattyn25-Sep-10 8:55 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 9:34
Trevor Johansen25-Sep-10 9:34 
GeneralRe: Memory aligned bit fields Pin
Luc Pattyn25-Sep-10 9:45
sitebuilderLuc Pattyn25-Sep-10 9:45 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 10:57
Trevor Johansen25-Sep-10 10:57 
AnswerRe: Memory aligned bit fields Pin
Luc Pattyn25-Sep-10 11:18
sitebuilderLuc Pattyn25-Sep-10 11:18 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 11:56
Trevor Johansen25-Sep-10 11:56 
GeneralRe: Memory aligned bit fields Pin
Luc Pattyn25-Sep-10 12:14
sitebuilderLuc Pattyn25-Sep-10 12:14 
GeneralRe: Memory aligned bit fields Pin
Alain Rist25-Sep-10 9:57
Alain Rist25-Sep-10 9:57 
GeneralRe: Memory aligned bit fields Pin
Aescleal25-Sep-10 10:19
Aescleal25-Sep-10 10:19 
AnswerRe: Memory aligned bit fields Pin
Alain Rist25-Sep-10 11:26
Alain Rist25-Sep-10 11:26 
GeneralRe: Memory aligned bit fields Pin
Aescleal25-Sep-10 22:31
Aescleal25-Sep-10 22:31 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 10:51
Trevor Johansen25-Sep-10 10:51 

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.