This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Arm compiler 6 error when redefining __FILE

Hi, I want to redirect printf output to a serial port. A method for this is described here:

Libraries and Floating Point Support Guide: Redefining low-level library functions to enable direct use of high-level library functions in the C library (keil.com)

However, the code described there fails to compile with Arm compiler 6.16 (it compiles fine with GCC):

#include <stdio.h>
struct __FILE
{
  int handle;

};

/* FILE is typedef’d in stdio.h. */
FILE __stdout;

The error is:

error: redefinition of '__FILE'
struct __FILE
       ^
C:\Program Files\Arm\Development Studio 2021.1\sw\ARMCompiler6.16\bin\..\include\stdio.h:119:8: note: previous definition is here
struct __FILE {
       ^
1 error generated.

How can I fix this please?