- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Posted: 2023-04-25 11:53 PM
Compiler Error C0037 - Pointer to an interface
I have trouble getting my code working in Machine Expert V2.1. My code works in Codesys but not in Machine Expert and I'm getting the weird compiler error C0037 that 'prt' is not an input to my method but it clearly is!
The code translates with no errors but when I try to generate the code the compiler error appears.
I attached a compact example project.
Is this a bug in Machine Expert?
- Labels:
-
Modicon M2xx
- Tags:
- english
Link copied. Please paste this link to share this article on your social media post.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Posted: 2023-04-26 04:16 AM . Last Modified: 2023-04-26 04:17 AM
I found the problem by myself.
If you write into a interface method declaration the compiler attributes
{attribute 'call_after_global_init_slot' := '10001'}
{attribute 'call_after_online_change_slot' := '10001'}
You will get the described weird compiler error.
Just comment out the attributes in the interface implementation:
And remove the comments in the FB which implements the interface
Fixed.
I highly believe this isn't the intended behavior since its working in Codesys without those comments.
Link copied. Please paste this link to share this article on your social media post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Posted: 2023-04-26 01:07 AM . Last Modified: 2023-04-26 01:09 AM
I investigated the error a bit further. The problem is that I want to store a pointer of each function block which implements the interface 'ConfigServiceInt' into a struct 'RegistryData'.
Something like:
pObject : ConfigServiceInt := ADR(Function_Block_Which_Implements_The_Interface);
The function block which implements the interface will have a register method which passes the pointer of the function block to the struct.
Later in the code I want to iterate through the array and call methods through the interface. Something like:
RegistryData[i].pObject.Some_Interface_Method();
Link copied. Please paste this link to share this article on your social media post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Posted: 2023-04-26 04:16 AM . Last Modified: 2023-04-26 04:17 AM
I found the problem by myself.
If you write into a interface method declaration the compiler attributes
{attribute 'call_after_global_init_slot' := '10001'}
{attribute 'call_after_online_change_slot' := '10001'}
You will get the described weird compiler error.
Just comment out the attributes in the interface implementation:
And remove the comments in the FB which implements the interface
Fixed.
I highly believe this isn't the intended behavior since its working in Codesys without those comments.
Link copied. Please paste this link to share this article on your social media post.

