piotrKask
Hi everyone,
I’m trying to use an ESP32 with OpenPLC and I’m running into a compilation error when using an external variable in my Structured Text program.

I send you below the log of compilation:
C:\Users\Piotl\OpenPLC_Editor\editor\arduino\src\lib/accessor.h:71:30: error: implicit declaration of function '__GET_GLOBAL_DUTY' [-Wimplicit-function-declaration]
71 | name.value = __GET_GLOBAL_##global();\
| ^~~~~~~~~~~~~
C:\Users\Piotl\OpenPLC_Editor\editor\arduino\src\POUS.c:16:3: note: in expansion of macro '__INIT_EXTERNAL'
16 | __INIT_EXTERNAL(REAL,DUTY,data__->DUTY,retain)
| ^~~~~~~~~~~~~~~
C:\Users\Piotl\OpenPLC_Editor\editor\arduino\src\lib/accessor.h:71:28: error: assignment to 'IEC_REAL *' {aka 'float *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
71 | name.value = __GET_GLOBAL_##global();\
| ^
C:\Users\Piotl\OpenPLC_Editor\editor\arduino\src\POUS.c:16:3: note: in expansion of macro '__INIT_EXTERNAL'
16 | __INIT_EXTERNAL(REAL,DUTY,data__->DUTY,retain)
| ^~~~~~~~~~~~~~~
C:\Users\Piotl\OpenPLC_Editor\editor\arduino\src\POUS.c: In function 'PROGRAM1_init__':
C:\Users\Piotl\OpenPLC_Editor\editor\arduino\src\lib/accessor.h:71:28: error: assignment to 'IEC_REAL *' {aka 'float *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
71 | name.value = __GET_GLOBAL_##global();\
| ^
C:\Users\Piotl\OpenPLC_Editor\editor\arduino\src\POUS.c:48:3: note: in expansion of macro '__INIT_EXTERNAL'
48 | __INIT_EXTERNAL(REAL,DUTY,data__->DUTY,retain)
| ^~~~~~~~~~~~~~~
Multiple libraries were found for "WiFi.h"
Used: C:\Users\Piotl\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.2\libraries\WiFi
Not used: C:\Users\Piotl\Documents\Arduino\libraries\WiFiNINA
Using library src in folder: C:\Users\Piotl\OpenPLC_Editor\editor\arduino\src (legacy)
Using library WiFi at version 3.3.2 in folder: C:\Users\Piotl\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.2\libraries\WiFi
Using library Networking at version 3.3.2 in folder: C:\Users\Piotl\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.2\libraries\Network
Using library lib in folder: C:\Users\Piotl\OpenPLC_Editor\editor\arduino\src\lib (legacy)
Used library Version Path
src C:\Users\Piotl\OpenPLC_Editor\editor\arduino\src
WiFi 3.3.2 C:\Users\Piotl\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.2\libraries\WiFi
Networking 3.3.2 C:\Users\Piotl\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.2\libraries\Network
lib C:\Users\Piotl\OpenPLC_Editor\editor\arduino\src\lib
Used platform Version Path
esp32:esp32 3.3.2 C:\Users\Piotl\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.2
Error during build: exit status 1
$? = 1
Build phase <function build.<locals>.build_project at 0x000001E5517FEF70> failed

The problem occured when i added the global variable called 'duty':
[203128%2F9527881%2Fmceclip0]

I am using this variable in program0 and program1 as an external variable, but it's not working.
[203128%2F9527884%2Fmceclip0]
 
[203128%2F9527886%2Fmceclip0]
 
In addition to that I've got the latest version of the OpenPlc Editor.

Thank you in advance for help.
Reply 0 0
thiagoralves
Update your editor (file -> check for updates) and try again
Reply 0 0
yonush
When you declare the variable as global in res0 it triggers a forward declaration error with the Arduino compiler when you add a global variable. I found if I add an Arduino Extension (no need to add any other code) and declared the variable there instead, it registers it as a global and compiles just fine. As you can see below it adds the variable as a global. I am running the most recent update of the editor and Arduino compiler+tools. I suspect its just a quirk in the order of the files/variable during the C compilation part. I has the same issue arise when I was writing the board/device code for the Raspberry Pico family.
[203128%2F9537439%2Fmceclip0]
Reply 0 0
Reply