Known Issues and Frequently Asked Questions¶
Supported compiler toolchains:
- GCC 4.7.3
Caution
Support for Windriver DIAB 5.9.2 has been dropped.
Supported compiler toolchains for AC500 PLCs are shipped along with Automation Builder.
If using another version or another C/C++ cross compiler toolchain or to modify the predefined environment settings, the compiler settings must be configured manually:
From the Tools menu select Options. From the menu list select C compiler settings.
- ⇒
Defining compiler settings.
Open the GCC <> tab.
Under Environment Variables click New to enter the path to compiler executable.
Under Include path click New to add custom include paths. The include path to FWAPI is automatically detected and cannot be changed.
Caution
Changes on the preset FWAPI path lead to ending support service.
Specifying optimization level –Os (size) for GCC results in linker errors:
When optimizing for size, GCC uses primitives for saving and restoring GPR and FPR registers from libgcc. Since C/C++ application is not linked against libgcc, this results in link errors (symbol not found). Therefore optimization level –Os is not available in the compiler settings.
Restrictions on C :
Language elements: ANSI C and C99 language extension are supported.
Restrictions on C++ :
Online change functionality is not available, if C++ toolchain is used. After changes in IEC application part, always a full download will occur.
Language elements: ISO C++98 and ISO C++2003 C++ dialects are supported as it is supported by GCC –std option.
We currently do not support:
- RTTI (Runtime Type Information)
- Exceptions
When existing code is imported, please ensure that the code works with these restrictions.
Restrictions for PM595:
Do not use 64-bit data types (LREAL, LINT, ULINT, LWORD) as return value of Function POUs.
Workaround: Use either Function Block POU, or encapsulate 64-bit return values in a STRUCT declaration and return this data instead.
Problems with accessing Function Block parameters from C/C++ application:
In order to convert the parameter names of POUs or DUTs automatically, follow the following rules:
- Function Block parameters/DUT members get converted to uppercase (e.g. FirstParam -> FIRSTPARAM).
- Function parameters get converted to uppercase and a postfix is added (e.g. abc -> ABCparam).
Using standard output/standard error:
Access to standard streams (e.g. via printf, puts, etc.) is not available. Please use standard file access instead (e.g. fprintf, fputs, etc.).
Supported parts of C standard library:
Note
A description on available functions in the standard library (FWAPI functions) is provided under <AB InstallDirectory>\CCodeToolchain\FWAPI\2.4\doc\index.html.
Header | Description | Supported | Remarks |
---|---|---|---|
assert.h | Contains the assert macro, used to assist with detecting logical errors and other error types in debugging versions of a program. | Yes | - |
complex.h | A set of functions for manipulating complex numbers. | Yes | - |
ctype.h | Defines a set of functions used to classify characters by their types or to convert between uppercase and lowercase in a way that is independent of the used character set (typically ASCII or one of its extensions, although implementations utilizing EBCDIC are also known). | Partially | Not supported: setchrclass |
errno.h | For testing error codes reported by library functions. | Yes | - |
fenv.h | Defines a set of functions for controlling floating-point environment. | Yes | - |
float.h | Defines macro constants specifying the implementation-specific properties of the floating-point library. | Yes | - |
inttypes.h | Defines exact-width integer types. | Yes | - |
iso646.h | Defines several macros that are equivalent to some of the operators in C. For programming in ISO-646 variant character sets. | Yes | - |
limits.h | Defines macro constants specifying the implementation-specific properties of the integer types. | Yes | - |
locale.h | Defines localization functions. | Yes | Standard C/POSIX locales only |
math.h | Defines common mathematical functions. | Partially (ANSI and C99) | Not supported: Macros: NAN, HUGE VAL |
setjmp.h | Declares the macros setjmp and longjmp, which are used for non-local exits. | Yes | - |
signal.h | Defines signal handling functions. | No | - |
stdalign.h | For querying and specifying the alignment of objects. | No | Part of C11: Not supported by GCC 4.7.3 |
stdarg.h | For accessing a varying number of arguments passed to functions. | Yes | - |
stdatomic.h | For atomic operations on data shared between threads. | No | Part of C11: Not supported by GCC 4.7.3 |
stdbool.h | Defines a boolean data type. | Yes | - |
stddef.h | Defines several useful types and macros. | Yes | - |
stdint.h | Defines exact-width integer types. | Yes | - |
stdio.h | Defines core input and output functions. | Partially | Not supported: Operations on files: tmpfile, tmpnam File access: freopen, setbuf, setvbuf Formatted input/output: scanf, vscanf Character input/output: getc, getchar, gets, ungetc Error-handling: clearerr, ferror, perror Macros: BUFSIZ, FILENAME_MAX, FOPEN_MAX, L_tmpnam, TMP_MAX |
stdlib.h | Defines numeric conversion functions, pseudo-random numbers generation functions, memory allocation, process control functions. | Partially | Not supported: Pseudo-random sequence generation: srand Environment: abort, atexit, at_quick_exit, exit, getenv, quick_exit, system, _Exit Integer arithmetics: llabs, lldiv Multibyte characters /strings: mblen, mbtowc, wctomb, mbstowcs, wcstombs Macros: EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX |
stdnoreturn.h | For specifying non-returning functions. | No | Part of C11: Not supported by DIAB C lib and GCC 4.7.3 |
string.h | Defines string handling functions. | Partially | Not supported: Comparison: strcoll, strxfrm Searching: strtok (alternative: strtok_r) Other: strerror |
tgmath.h | Defines type-generic mathematical functions. | Yes | - |
threads.h | Defines functions for managing multiple threads as well as mutexes and condition variables. | No | Part of C11: Not supported by GCC 4.7.3 |
time.h | Defines date and time handling functions. | Partially | Not supported: Conversion: localtime |
uchar.h | Types and functions for manipulating unicode characters. | No | - |
wchar.h | Defines wide string handling functions. | No | - |
wctype.h | Defines set of functions used to classify wide characters by their types or to convert between uppercase and lowercase. | No | - |
Supported parts of C++ standard library:
Note
A description on available functions in the standard library (FWAPI functions) is provided under <AB InstallDirectory>\CCodeToolchain\FWAPI\2.4\doc\index.html.
Header | Description | Supported |
---|---|---|
<c*> (.h) | C library headers | Yes |
array | Containers | No |
bitset | Containers | No |
deque | Containers | No |
forward_list | Containers | No |
list | Containers | No |
map | Containers | No |
queue | Containers | No |
set | Containers | No |
stack | Containers | No |
unordered_map | Containers | No |
unordered_set | Containers | No |
vector | Containers | No |
ios | Input/output base classes | No |
streambuf | Stream buffer | No |
istream | Input streams | No |
ostream | Output streams | No |
iostream | Standard input/output streams library | No |
fstream | File streams | No |
sstream | String streams | No |
iomanip | IO manipulators | No |
iosfwd | Input/output forwarding | No |
atomic | Atomics and threading library | No |
condition_variable | Atomics and threading library | No |
future | Atomics and threading library | No |
mutex | Atomics and threading library | No |
thread | Atomics and threading library | No |
algorithm | Algorithms | No |
chrono | Time | No |
complex | Complex numbers | No |
functional | Function objects | No |
initializer_list | Initializer list | No |
iterator | Iterator definitions | No |
limits | Numeric limits | No |
memory | Memory elements | No |
new | Dynamic memory | Yes |
numeric | Generalized numeric operations | No |
random | Random | No |
ratio | Ratio header | No |
regex | Regular expressions | No |
string | Strings | No |
system_error | System errors | No |
tuple | Tuple library | No |
typeindex | Type index | No |
typeinfo | Type information | No |
type_traits | type_traits | No |
utility | Utility components | No |
valarray | Library for arrays of numeric values | No |
Floating point instructions:
Support for floating point instructions (single and double precision) in hardware.
Debugging:
At the moment the development environment does not support debugger, i.e. debugging while running on PLC target is not possible.
Linking third-party binaries or libraries:
At the moment it is not possible to link against third-party binaries or libraries.
Adding third-party source code to C/C++ applications:
Compiler/linker options for compiling C/C++ code:
Caution
These compiler/linker settings are activated by default, and cannot be changed by end-users, since otherwise compilation/linking may fail or lead to unexpected results.
In addition to that, following options are configurable by end users via C/C++ compiler settings dialog.
Type of PLC | GCC (C) | G++ (C++) |
---|---|---|
PM55x, PM56x, PM57x, PM58x | -mcpu=860 -fno-common -msdata=none -fno-jump-tables -fno-section-anchors -fno-merge-constants -fno-builtin -nostdlib -Wconversion -Werror-implicit-function-declaration fstack-usage |
- |
PM590, PM591, PM592 | -mcpu=603e -fno-common -msdata=none -fno-jump-tables -fno-section-anchors -fno-merge-constants -fno-builtin -nostdlib -Wconversion -Werror-implicit-function-declaration fstack-usage |
-fmessage-length=0 -fno-rtti -fomit-frame-pointer -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables |
PM595 | -mcpu=8540 -mdouble-float -mfloat-gprs=double -mspe -mabi=spe -fno-common -msdata=none -fno-jump-tables -fno-section-anchors -fno-merge-constants -fno-builtin -nostdlib -Werror-implicit-function-declaration -Wconversion -fstack-usage |
- |
Dialect options:
Option | GCC (C) |
---|---|
C99 | -std=c99 |
ANSI | -ansi |
Option | GCC (C) |
---|---|
ISO C++98 | -std=c++98 |
ISO C++03 | -std=c++03 |
Optimization options:
Option | GCC (C) and G++ (C++) |
---|---|
none | - |
normal | -O2 |
extra | -O3 |
Linker options:
Note
Linker options are used in exactly the order as shown in the following table.
C | C++ |
---|---|
–emit-relocs –no-check-sections -L%TOOLCHAINPATH%\powerpc-elf-eabi\lib -L%TOOLCHAINPATH%\lib\gcc\powerpc-elf-eabi\4.7.3 |
–emit-relocs –no-check-sections -L%TOOLCHAINPATH%\powerpc-elf-eabi\lib -L%TOOLCHAINPATH%\lib\gcc\powerpc-elf-eabi\4.7.3 |
%TOOLCHAINPATH%\lib\gcc\powerpc-elf-eabi\4.7.3\ecrti.o %TOOLCHAINPATH%\lib\gcc\powerpc-elf-eabi\4.7.3\crtbegin.o |
|
userapplication.obj | userapplication.obj |
- | -lstdc++ |
- | %TOOLCHAINPATH%\lib\gcc\powerpc-elf-eabi\4.7.3\crtend.o %TOOLCHAINPATH%\lib\gcc\powerpc-elf-eabi\4.7.3\ecrtn.o |
%TOOLCHAINPATH%\powerpc-elf-eabi\lib\lib_a-setjmp.o %FWAPIPATH%\libFWAPI.a” -o user_libname.obj –strip-debug –script=ac500_link_script |
%TOOLCHAINPATH%\powerpc-elf-eabi\lib\lib_a-setjmp.o %FWAPIPATH%\libFWAPI.a” -o user_libname.obj –strip-debug –script=ac500_link_script |
Why are VAR_IN_OUT parameters of a Function Block not initialized in corresponding init function?
During initialization of the Function Block the pointer BYTE \*B;
is not valid. It is getting valid during first call of the Function Block in IEC, therefore it is first accessible in FB main function code.
CODESYS compiler complains about unresolved symbols _f_sub, __subsf3, …:
Your PLC uses math emulation. Please include math standard library (math.h) to support this.
Type char:
Type char
is implemented as unsigned char
. Hence, its definition is equal to IEC type BYTE.
Why does GCC generate code that aborts application when va_list is used?
If you use va_list
, GCC performs an automatic type promotion of the list members:
char/short
➔int
unsigned char/unsigned short
➔unsigned int
float
➔double
When extracting list members with va_arg()
, ensure using the promoted type (e.g. int
instead of char
). We recommend you, to check the compiler warnings. In case of type mismatch, GCC will throw a warning similar to the following:
warning: 'unsigned char' is promoted to 'int' when passed through '...' [enabled by default]
note: (so you should pass 'int' not 'unsigned char' to 'va_arg')
note: if this code is reached, the program will abort
Caution
In this case call to va_arg()
. Otherwise GCC will insert a trap instruction, that halts your application.
Parameters of POU or the members of data types defined in Automation Builder differ from definition in C sources:
On code generation, parameters of POU and members of data types are slightly transformed:
- Names of POU and data types are converted to uppercase (e.g. mypou -> MYPOU).
- Parameters of POUs and members of data types are converted to uppercase.
- Parameters of POU type FUNCTION: A postfix “param” is added (e.g. myByte -> MYBYTEparam).
Number of POUs or data types for a Automation Builder project:
Up to 50 POUs or data types can be created in one single Automation Builder project.
Searching for a POU or data type name in Automation Builder:
Search with Edit -> Find/Replace -> Find does not work is not supported yet.
Online change after changes in C/C++ application parts:
After a change in C/C++ application part, online change is not possible. Perform a “Clean All” function before downloading to PLC.
If changes are in IEC code only, online changes are still possible.