Hello, I am trying to create custom function blocks in C++. When I try to use function/function blocks from B&R libraries (ArCAN/AsTime/AsIOTime) I seem to be getting error 5882 compile error. Is there something else I had to do other than #include them?
Hi,
Iād generally recommend posting a minimal example so people know what your current code looks like.
The error 5882 would let me think you are trying to access a FB instance that you made globally - which doesnāt work.
Generally speaking, everything a FB needs to access needs to be contained in there, so you need to have an instance of the FUB as part of your own FUBās interface.
Additionally fyi, there is usually no need to add āincludeā statements for libs manually (neither in tasks nor libs) - in tasks, the default include mechanism exists and works and in libs you can add any lib you want as a dependency and it will therefore also already be included by the automatically created header file.
Example with āastimeā usage appended
Library.zip (6.9 KB)
Best regards
Michael
Hello Michael,
Thanks for pointing out.
I think I missed a crucial information here. I was doing it in AS6.
Today I tried to import the same library as reference into a test project in AS4.12 and it is able to compile.
The error will already occur (in AS6 only) with a simple call of clock_ms() from AsTime.
Here is my pseudo code example
#include <bur/plctypes.h>
#include "simpleCAN.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "ArCan.h"
#include "AsIOTime.h"
#include "AsTime.h"
unsigned long bur_heap_size = 0xFFFF;
void simpleCAN(struct simpleCAN* inst){
if (inst->Enable)
{
if (inst->Active)
{
plctime currentTime = clock_ms();
}else
{
inst->internal.steps = SCAN_INIT;
}
}else
{
inst->internal.steps = SCAN_ENABLE_FALSE;
}
...
Since it only seems to occur in AS6 not sure if there was some setting I had to change, or it may be a bug Iāll create a ticket on this.
Best,
Samuel
Hi everyone,
An update on the issue. It seems to be some bugs will be taken into consideration in AS6.1 update.
Workaround: add build option ā-u__cxa_begin_cleanupā to additional build options of the library.
I get the same error 5882 (āUnknown PV __cxa_begin_cleanupā) when converting a project from AS 4.12.6, where there are no errors, to AS 6.0.2.177. However, your suggested solution of entering ā-u__cxa_begin_cleanupā as āadditional build optionsā does not help either, as this only generates further errors ( āundefined reference to ābur_heap_sizeāā ).
The error seems to be related to the heap management in c/c++ code ? According to the help, nothing has changed there.
Hello Ludger,
Do you have bur_heap_size variable declare somewhere in the C++ library/Code (see the pseudo code above)?
For my case I will also get the āundefined reference to ābur_heap_sizeā" if I donāt declare it in any one of the .cpp files in my library. And seems like it will share the same heap allocation across the entire library.
Hello Samuel,
I added āunsigned long bur_heap_sizeā to my library code. But this only replaces error 5882 with another error: the linker (?) now complains about āmultiple definition of bur_heap_sizeā ā¦ so fixing one error generates only new errors.
I am frustated and will stop the conversion of my project to AS 6, as I now believe that the C/C++ integration is broken. Maybe there will be an AS6 version in the future that can be used in production ā¦
with regards
Ludger
Hello Samuel,
I just found a workaround that works for my code:
Implement a std::string variable somewhere in your code and the error 5882 is gone. e.g. : the line āstd::string dummy(ātestā);ā together with an '#include <string> is sufficient.
As I understand, __cxa_begin_cleanup is defined in libsupc++ and is part of the exception handling for ARM CPUs (the CPU I am using is a CP0484 which has an ARM CPU). Therefore, at least in my case, the error is not related to the bur_heap_size variable.
Ludger