<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Warning C0564 when compiling CNC project with variables program</title><link href="https://forge.codesys.com/forge/talk/Motion/thread/d722ad430e/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Motion/thread/d722ad430e/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Motion/thread/d722ad430e/</id><updated>2024-04-30T15:06:15.864000Z</updated><subtitle>Recent posts to Warning C0564 when compiling CNC project with variables program</subtitle><entry><title>Warning C0564 when compiling CNC project with variables program</title><link href="https://forge.codesys.com/forge/talk/Motion/thread/d722ad430e/?limit=25#40f5" rel="alternate"/><published>2024-04-30T15:06:15.864000Z</published><updated>2024-04-30T15:06:15.864000Z</updated><author><name>gseidel</name><uri>https://forge.codesys.com/u/gseidel/</uri></author><id>https://forge.codesys.com2edf6cab507c3a7cd6e904054b270b2b048a9990</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Fless,&lt;/p&gt;
&lt;p&gt;thanks for your report!&lt;/p&gt;
&lt;p&gt;We created an issue in our bug tracker (SM-5109) and will have a look at this issue.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Georg&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Warning C0564 when compiling CNC project with variables program</title><link href="https://forge.codesys.com/forge/talk/Motion/thread/d722ad430e/?limit=25#2236" rel="alternate"/><published>2024-04-02T13:11:22.236000Z</published><updated>2024-04-02T13:11:22.236000Z</updated><author><name>Fless</name><uri>https://forge.codesys.com/u/fless/</uri></author><id>https://forge.codesys.com7c1ad8f9ed95f8ff934185f9f5245e9de9205a37</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;br/&gt;
We managed to avoid the warnings by changing the order of initialization by adding an attribute to the GVL with the variables.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;attribute&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="nv"&gt;global_init_slot&lt;/span&gt;&lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="mi"&gt;49989&lt;/span&gt;&lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The variables are initialized right before the regular GVLs (default GVL slot 49990).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note to Codesys:&lt;/strong&gt;&lt;br/&gt;
I see the problem, Codesys needs to initialize the CNC objects before the GVLs so they can be used in the GVL. But then you can't use variables from GVLs in CNC programs. Maybe you could disable the warning in your generated CNC objects?&lt;br/&gt;
At least a note for a workaround would have been nice.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Warning C0564 when compiling CNC project with variables program</title><link href="https://forge.codesys.com/forge/talk/Motion/thread/d722ad430e/?limit=25#5ac6" rel="alternate"/><published>2024-03-21T11:11:50.629000Z</published><updated>2024-03-21T11:11:50.629000Z</updated><author><name>Fless</name><uri>https://forge.codesys.com/u/fless/</uri></author><id>https://forge.codesys.com49318c3dadeebae0b89079241d7915cbab76e6f2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;we are porting a CNC project from codesys 3.5.16 to codesys 3.5.19.&lt;br/&gt;
The project has lots of CNC programs with variables.&lt;/p&gt;
&lt;p&gt;now we get hundreds of messages like this.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span&gt;[WARNING]&lt;/span&gt;       CNC Test  SP19: TestCNC &lt;a class="" href="../Line%201,%20Column%201"&gt;SPS: PLC Logic: Application&lt;/a&gt;: C0564:  A reference to uninitialized variable varCNC is used for initialization of TestCNC_D. Accessing the uninitialized variable may result in unexpected behavior.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The objects &lt;em&gt;program_name&lt;/em&gt;_D are implicit generated by codesys. I see no way to generated them after the variables.&lt;br/&gt;
Is there a way to correct the initialization order?&lt;/p&gt;
&lt;p&gt;We know how to suppress this warning.&lt;br/&gt;
But we need a clean solution as the warning already saved us in a other nonCNC project.&lt;/p&gt;
&lt;p&gt;Attached a small demo of the problem.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>