Kang
Dear sir
 
I use the C extension in ST function block, when I include the <sys/msg.h> in the ST program, it showed the compile error below.
 
What I want to achieve is using message queue in linux to have the communication between PLC thread and my other thread.
 
How can I deal with this situation? Or is there anything to set in my editor environment?
 
[203128%2F9419338%2Fmceclip0]
Reply 0 0
thiagoralves
You can’t include header files inside pragmas. The only way to make it work is to encapsulate your Linux specific code in a #ifdef statement and include the library files you need in the runtime source code on your Linux target
Reply 0 0
Kang
You can’t include header files inside pragmas. The only way to make it work is to encapsulate your Linux specific code in a #ifdef statement and include the library files you need in the runtime source code on your Linux target
So the purpose to add the #ifdef is that, the editor will not compile the C code in ifdef, it will only be compiled when the .st file is uploaded to the PLC runtime?  
 
Here is the way I understand, I #include the <time.h> in #ifdef in ST code, then I #define a same macro in the PLC runtime code like main.cpp or ladder. h. to compile it in runtime code. Is it correct?
[203128%2F9421677%2Fmceclip0]
 
However, I still got the compile error in my runtime complier, like below, do you know the reason or where I did it wrong?
[203128%2F9421678%2Fmceclip0]
Reply 0 0
thiagoralves
You still cannot include library files in the pragmas. The #ifdef directive is only to exclude your linux specific code from the editor compiler. As I said in my previous post, you need to add your library header files inside one of the included files in the runtime source code.
Reply 0 0
Kang
You still cannot include library files in the pragmas. The #ifdef directive is only to exclude your linux specific code from the editor compiler. As I said in my previous post, you need to add your library header files inside one of the included files in the runtime source code.
Hi, thiagoralves
 
Another question is that, is there any other method to call C code library or using C code language in function block besides this method?
Reply 0 0
thiagoralves
On v3 that's the only way. On v4 you will be able to write function blocks in C++ or Python directly, and that's going to allow you to write full C++ or Python programs as function blocks, even with imports and #include libraries.
Screenshot 2025-08-08 at 10.17.43 AM.png
Reply 0 0
Kang
On v3 that's the only way. On v4 you will be able to write function blocks in C++ or Python directly, and that's going to allow you to write full C++ or Python programs as function blocks, even with imports and #include libraries.
Screenshot 2025-08-08 at 10.17.43 AM.png
Hi, thiagoralves
 
It is good to hear this, and I also noticed that the v4 will be able to support the structure and array data monitoring .
 
And when will the v4 be released? Any plan for release?
Reply 0 0
thiagoralves
We’re aiming for a release in Q1 2026. Features will be incrementally added as the platform evolves. Stay tuned
Reply 0 0
Evenmerk
On v3 that's the only way. On v4 you will be able to write function blocks in C++ or Python directly, and that's going to allow you to write full C++ or Python programs as function blocks, even with imports and #include libraries.
Screenshot 2025-08-08 at 10.17.43 AM.png

Hi @thiagoralves does it mean using function block we can use a library for gpio extenders?

Reply 0 0
thiagoralves
Yes, as long as the library does not require any special compilation arguments
Reply 0 0
Reply