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

C / C++ / MFC

 
QuestionPostMessage failure. How best to proceed? Pin
Chris Meech11-Feb-08 8:38
Chris Meech11-Feb-08 8:38 
AnswerRe: PostMessage failure. How best to proceed? Pin
Nemanja Trifunovic11-Feb-08 8:50
Nemanja Trifunovic11-Feb-08 8:50 
GeneralRe: PostMessage failure. How best to proceed? Pin
Chris Meech11-Feb-08 9:48
Chris Meech11-Feb-08 9:48 
AnswerRe: PostMessage failure. How best to proceed? Pin
Mark Salsbery11-Feb-08 9:11
Mark Salsbery11-Feb-08 9:11 
GeneralRe: PostMessage failure. How best to proceed? Pin
Chris Meech11-Feb-08 9:53
Chris Meech11-Feb-08 9:53 
GeneralRe: PostMessage failure. How best to proceed? Pin
Cedric Moonen11-Feb-08 20:24
Cedric Moonen11-Feb-08 20:24 
GeneralRe: PostMessage failure. How best to proceed? Pin
Mark Salsbery12-Feb-08 5:32
Mark Salsbery12-Feb-08 5:32 
QuestionAuto-byte-swapping that can be used in a union [modified] Pin
ClementsDan11-Feb-08 6:56
ClementsDan11-Feb-08 6:56 
We've got a bunch of apps that need to prepare data for a machine that uses big-endian byte order. So we have a bunch of structs that look like:

struct tagFOO_COMREG
{
   UINT16  ui16DataLength_BE;
   UINT32  ui32SeqNum_BE;
   // ...
} FOO_COMREG_s, *PFOO_COMREG_s;


where the _BE is a reminder that these values have to be byte-swapped.

So, one day I thought it would be convenient to be able to assign to one of the struct members without having to explicitly do the byte swapping. So I wrote some classes like:

class UINT16_BE
{
   private:
      BYTE m_abData[2];
   public:
      UINT16_BE(void)
      {
         // do nothing
      }
      UINT16_BE(UINT16 ui16)
      {
         m_abData[0] = static_cast<BYTE>(ui16 >> 8);
         m_abData[1] = static_cast<BYTE>(ui16);
      }
      operator UINT16(void)
      {
         return ((m_abData[0] << 8) | m_abData[1]);
      }
};


And it works fine. Until my co-worker comes up to me asking how to fix a compiler error he's having. He's trying to put these in a union, which doesn't work because the constructors keep it from being recognized as POD (despite the fact that the class was designed to be memcpy-able).

So, is there a way around this?

modified on Monday, February 11, 2008 2:13 PM

GeneralRe: Auto-byte-swapping that can be used in a union [modified] Pin
Mark Salsbery11-Feb-08 7:29
Mark Salsbery11-Feb-08 7:29 
GeneralRe: Auto-byte-swapping that can be used in a union Pin
led mike11-Feb-08 7:47
led mike11-Feb-08 7:47 
GeneralRe: Auto-byte-swapping that can be used in a union Pin
Mark Salsbery11-Feb-08 7:52
Mark Salsbery11-Feb-08 7:52 
GeneralDb query failing in MFC Pin
krishnan.s11-Feb-08 4:51
krishnan.s11-Feb-08 4:51 
GeneralAnd the errors are? Pin
jhwurmbach11-Feb-08 4:56
jhwurmbach11-Feb-08 4:56 
GeneralRe: And the errors are? Pin
krishnan.s11-Feb-08 4:59
krishnan.s11-Feb-08 4:59 
GeneralRe: And the errors are? Pin
krishnan.s11-Feb-08 5:00
krishnan.s11-Feb-08 5:00 
GeneralRe: And the errors are? Pin
jhwurmbach11-Feb-08 5:07
jhwurmbach11-Feb-08 5:07 
GeneralRe: Db query failing in MFC Pin
led mike11-Feb-08 5:08
led mike11-Feb-08 5:08 
GeneralRe: Db query failing in MFC Pin
krishnan.s11-Feb-08 17:33
krishnan.s11-Feb-08 17:33 
GeneralRe: Db query failing in MFC Pin
led mike12-Feb-08 5:34
led mike12-Feb-08 5:34 
Questionhow to add separator in list box Pin
coding_ram11-Feb-08 2:41
coding_ram11-Feb-08 2:41 
AnswerRe: how to add separator in list box Pin
David Crow11-Feb-08 2:56
David Crow11-Feb-08 2:56 
AnswerRe: how to add separator in list box Pin
Hamid_RT11-Feb-08 3:32
Hamid_RT11-Feb-08 3:32 
AnswerRe: how to add separator in list box Pin
Eytukan11-Feb-08 5:46
Eytukan11-Feb-08 5:46 
AnswerRe: how to add separator in list box Pin
coding_ram12-Feb-08 22:47
coding_ram12-Feb-08 22:47 
GeneralConvert INT32 to int Pin
orihime11-Feb-08 2:04
orihime11-Feb-08 2:04 

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.