Hi,

Have you placed __declspec before MBAP_Header too?
Yes:
Qt Code:
  1. //#pragma pack(1)
  2. __declspec(align(1)) struct MB_Request
  3. {
  4. uchar function_code;
  5. quint16 start_adr;
  6. quint16 quantity_regs;
  7. };
  8.  
  9. //#pragma pack(1)
  10. __declspec(align(1)) struct MBAP_Header
  11. {
  12. quint16 transaction_id;
  13. quint16 protocol_id;
  14. quint16 len;
  15. uchar unit_id;
  16. };
  17.  
  18. //#pragma pack(1)
  19. __declspec(align(1)) struct MB_Message
  20. {
  21. MBAP_Header mb_hdr;
  22. MB_Request mb_req;
  23. };
To copy to clipboard, switch view to plain text mode 

But
Qt Code:
  1. int iA1 = __alignof(MBAP_Header);
  2. int iA2 = __alignof(MB_Request);
  3. int iA3 = __alignof(MB_Message);
To copy to clipboard, switch view to plain text mode 
Returns always "2" for iA1, iA2 and iA3.

Don't worry about it, using "#pragma pack(1)" is going well.

Thanks for your time and your knowdelege.