This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PROCESSOR-SDK-AM64X: strrchr() error in strings.h if any non-zero optimization is set for compiler/linker.

Part Number: PROCESSOR-SDK-AM64X

Tool/software:

Arm Compiler/Linker shows error as below, for the standard lib header file strings.h, when -O1 or above optimization is enabled.

C:\ti\ti-cgt-armllvm_4.0.0.LTS\include\c\strings.h:83:11: error: cannot initialize return object of type 'char *' with an rvalue of type 'const char *'
83 | return strchr(a, b);
| ^~~~~~~~~~~~
C:\ti\ti-cgt-armllvm_4.0.0.LTS\include\c\strings.h:90:11: error: cannot initialize return object of type 'char *' with an rvalue of type 'const char *'
90 | return strrchr( a, b);
| ^~~~~~~~~~~~~~
2 errors generated.

  • Hi Leo,

    Thanks for your query.

    Arm Compiler/Linker shows error as below, for the standard lib header file strings.h, when -O1 or above optimization is enabled

    From the error message, I can see that the compiler is throwing error because the strrchr() and strchr() function are returning 'const char *' but your function return type might be 'char *' or the variable in which you are storing the return value might be of 'char *' which is creating problem here.

    Please keep the data type consistent, either typecast it to 'const char *' or 'char *'.

    Regards,

    Tushar