Strange behavior when calculating size of STRUCT

maoravni
2020-09-14
2020-09-17
  • maoravni - 2020-09-14

    Hi,

    I encounter strange STRUCT sizing in CodeSys.

    I have a STRUCT with various members, with various sizes. There's no real logic to the order in which the members are located, and I can't change the order. The member are all basic types, and range from BOOL to LREAL and UDINT. The STRUCT is pack_mode 1 due to the fact that it's dumped to disk every few seconds.

    When I perform a SIZEOF or VAR_INFO of the struct I get the same number - 324 bytes.

    When I count the individual sizes of each of the members I get 332 bytes.

    This is strange to me, as I would expect SIZEOF to be the same as the individual members in pack_mode 1, and larger when using other pack_modes.

    Any ideas?

     
    • nothinrandom - 2020-09-17

      Could you share example of the struct?

       
  • i-campbell

    i-campbell - 2020-09-14

    Download CODESYS memory tools from the store and take a look at the memory.

     

Log in to post a comment.