<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Struct alignment with FB parameters in external library</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/8635bcf179/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/8635bcf179/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/8635bcf179/</id><updated>2020-02-27T22:59:35.375000Z</updated><subtitle>Recent posts to Struct alignment with FB parameters in external library</subtitle><entry><title>Struct alignment with FB parameters in external library</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/8635bcf179/?limit=25#973a" rel="alternate"/><published>2020-02-27T22:59:35.375000Z</published><updated>2020-02-27T22:59:35.375000Z</updated><author><name>Fox</name><uri>https://forge.codesys.com/u/fox/</uri></author><id>https://forge.codesys.com488a1f8bd116fcf353ee620fabca96d172892b76</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;shooter hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
make it a little bigger and you will see more discrepancies.&lt;br/&gt;
Surely I will if struct alignment settings are diffenent &lt;br/&gt;
&lt;strong&gt;shooter hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
yes it does because there is a header on a structure.&lt;br/&gt;
You mean there is no way to solve that, for example with some pragmas?&lt;br/&gt;
I've tried to set 1-byte alignment option within VC++b(with "" command), but it doesn't work (I'm still trying to find out the reason).&lt;br/&gt;
I'm confused  &lt;/p&gt;
&lt;/blockquote&gt;&lt;/div&gt;</summary></entry><entry><title>Struct alignment with FB parameters in external library</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/8635bcf179/?limit=25#e33d" rel="alternate"/><published>2020-02-27T22:59:33.624000Z</published><updated>2020-02-27T22:59:33.624000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com504870d7c3997d25ea6ab7a8e3d076f5c55195d8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;yes it does because there is a header on a structure.&lt;br/&gt;
make it a little bigger and you will see more discrepancies.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Struct alignment with FB parameters in external library</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/8635bcf179/?limit=25#7d50" rel="alternate"/><published>2020-02-27T22:59:29.116000Z</published><updated>2020-02-27T22:59:29.116000Z</updated><author><name>Fox</name><uri>https://forge.codesys.com/u/fox/</uri></author><id>https://forge.codesys.com84c7bd3fe643b04067a7f09fbd5da85a709f63a2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi all.&lt;br/&gt;
I'm developing my own external library (with Visual C++ 6.0) and lately encountered with interesting bug that I fixed in abnormal (by my consideration) way. I would like to get rid of that abnormal fixing. Currently I have no real PLC and execute my experiments with "SP PLCWinNT v2.4" simulator.&lt;br/&gt;
There is an example Function Block declared in my lib-project:&lt;/p&gt;
&lt;p&gt;There is a h-file automatically generated by CoDeSys:&lt;/p&gt;
&lt;p&gt;Please notice on F_Reserv parameter. I don't need it and it is my way of fixing the following problem: when my parameter list is declared without F_Reserv - the structure alignment in the compiled C-code and in the PLC memory is different. The &lt;span style="color: #0040FF;"&gt;sizeof&lt;/span&gt;(LIB_FUNCtyp) is equal to 24 bytes in compiled C-code (that is perfectly correct due to 4-byte struct alignment set in project's Options) , but it seems that it equals to 21 bytes in PLC memory, cause debug process shows complete mess with values. &lt;br/&gt;
So when I declare &lt;strong&gt;F_Reserv    : ARRAY&lt;span&gt;&lt;span&gt;[1..3]&lt;/span&gt;&lt;/span&gt; OF BOOL&lt;/strong&gt; in CoDeSys (forcing appropriate struct alignment) and comment (disable) the corresponding line &lt;strong&gt;BOOL F_RESERV&lt;span&gt;&lt;span&gt;[3]&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt; in C-code - my Function Block performs as designed.&lt;br/&gt;
How should I get rid of that unwanted declaration? There are no any alignment parameters in Target settings of Soft PLC and it seems that it uses 1-byte alignment option. &lt;/p&gt;
&lt;p&gt;I feel there should be a simpler way to solve that.&lt;br/&gt;
Thanks.&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Bild" rel="nofollow" src="http://i.snag.gy/BLPNT.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Bild" rel="nofollow" src="http://i.snag.gy/wKfML.jpg"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>