Why do I get C0434: Function block AbstractFunctionBlock is ABSTRACT and cannot be instantiated for a Reference?

2022-08-14
2022-08-14
  • thecolonel26 - 2022-08-14
    VAR_INPUT
        RefToFBs : REFERENCE TO ARRAY [0..49] OF AbstractFunctionBlock;
    END_VAR
    

    Error

    C0434:  Function block AbstractFunctionBlock is ABSTRACT and cannot be instantiated
    

    That is not the actual instance it is just a reference declaration, so why am I getting that error?

    I want to pass references to derived types, this object only needs access to things that are in the base function block.

     

    Last edit: thecolonel26 2022-08-14
  • hermsen

    hermsen - 2022-08-14

    please read up on ABSTRACT in the help and you will understand what you are doing is incorrect... as ABSTRACT means you must mandatory EXTEND the ABSTRACT FB before you may use it.

     

    Last edit: hermsen 2022-08-14
    • thecolonel26 - 2022-08-14

      I have extended it, I have 2 derived types. But I want the to have the
      Reference point to either of the derived types. Since it is only a
      Reference it seems to me it should work.

      I can do this with interfaces, but that is a lot of boiler plate code to wrap everything is properties.

      On Sun, Aug 14, 2022, 3:12 PM h-hermsen no-reply@codesys.com wrote:

      please read up on ABSTRACT in the help and you will understand what you
      are doing is incorrect... as ABSTRACT means you must EXTEND the ABSTRACT FB
      before you may use it.


      Why do I get C0434: Function block AbstractFunctionBlock is ABSTRACT and
      cannot be instantiated for a Reference?
      https://forge.codesys.com/forge/talk/Engineering/thread/2d12dfd265/?limit=250#d2c1


      Sent from forge.codesys.com because you indicated interest in
      https://forge.codesys.com/forge/talk/Engineering/

      To unsubscribe from further messages, please visit
      https://forge.codesys.com/auth/subscriptions/

       

      Last edit: thecolonel26 2022-08-14

Log in to post a comment.