Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Warning C0564 when compiling CNC project with variables program

Fless
2024-03-21
2024-04-02
  • Fless

    Fless - 2024-03-21

    Hello,

    we are porting a CNC project from codesys 3.5.16 to codesys 3.5.19.
    The project has lots of CNC programs with variables.

    now we get hundreds of messages like this.

    [WARNING] CNC Test SP19: TestCNC SPS: PLC Logic: Application: C0564: A reference to uninitialized variable varCNC is used for initialization of TestCNC_D. Accessing the uninitialized variable may result in unexpected behavior.

    The objects program_name_D are implicit generated by codesys. I see no way to generated them after the variables.
    Is there a way to correct the initialization order?

    We know how to suppress this warning.
    But we need a clean solution as the warning already saved us in a other nonCNC project.

    Attached a small demo of the problem.

     
  • Fless

    Fless - 2024-04-02

    Update:
    We managed to avoid the warnings by changing the order of initialization by adding an attribute to the GVL with the variables.

    {attribute 'global_init_slot' := '49989'}
    

    The variables are initialized right before the regular GVLs (default GVL slot 49990).

    Note to Codesys:
    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?
    At least a note for a workaround would have been nice.

     

Log in to post a comment.