Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3184

PB 12.6 issue: passing structure to external C++ function

$
0
0

Hello,

 

I'm just in the phase of migrating applications from PB 12.5.2 5629 to PB 12.6 4011.

My application uses calls of external functions residing in a C++ DLL with passing structures as arguments.

 

PB structure:

global type s_s7sbsbulk from structure

    boolean     bconn

    long        job

    integer     machine

    integer     silo

    integer     product

    long        setvalue

    long        actvalue

    integer     state

    byte        manual

end type

 

C++ struct:

#pragma pack(push, r1, 1) 

typedef struct S7SBSBulkData

{

   ULONG  m_lJobID;       // Job-ID

   short  m_sMachine;     // Machine-No. (1 or 2)

   short  m_sSilo;        // Source Silo (1 - 28)

   short  m_sSiloProduct; // product in silo

   ULONG  m_lSetValue;    // Setvalue in kg

   ULONG  m_lActValue;    // Actual values in kg

   short  m_sStatus;      // Silo-Status

   BYTE   m_bManual;      // manual input

} S7SBSBulkData;

 

// for GUI (Powerbuilder)

typedef struct S7SBSBLData

{

   WORD   bConn;           // Connection

 

   S7SBSBulkData m_Bulk;   // data of loading machine

} S7SBSBLData;

#pragma pack(pop, r1)   // stack popped


This worked well for years with PB 12.5.2.

After migrating to PB 12.6 it seems that the alignment of the structure elements in PB has changed.

It seems that each long variable starts now on an address that is a multiple of 4.


PB
C++
size
PB 12.5.2 address
PB 12.6 address
C++ address
boolWORD2000
longULONG4242
intshort2686
intshort28108
intshort2101210
longULONG4121612
longULONG4162016
intshort2202420
byteBYTE1222622


Is this a new feature of PB 12.6 or am I missing something?

 

Thanks

Werner

 

PS

This mean that I can't migrate migrate the projects to 12.6 without changing the c++ structures.


Viewing all articles
Browse latest Browse all 3184

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>