We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am using the template from Redefining low-level library functions to enable direct use of high-level library functions in the C library (can get you code embedder to work)
namespace std{struct __FILE{ int handle;};
FILE __stdout;FILE __stdin;FILE __stderr;
int fgetc(FILE *f){ int c; c = uart_read(); if(c =='\r'){ uart_write(c); c = '\n'; } uart_write(c); return c; }
int fputc(int c, FILE *stream){ return uart_write(c); } int ferror(FILE *stream){ return 1; } long int ftell(FILE *stream){ return 1;
} int fclose(FILE *f){ return 1; } int fseek(FILE *f, long nPos, int nMode){ return 0; } int fflush(FILE *f){ return 1; }
}
With the following header,
#ifndef __UART_H
#define __UART_H
#include "stm32f4xx.h"
#include <stdio.h>
// a whole load of function declarations
#endif
The compiler throws the following error,
error: redefinition of __FILE
struct __FILE
I using:
uVision V5.41.0.0
ArmClang V6.22
Target board - ST's NUF411RE
I have seen that this question has been posed before but the answer given in those cases was just to point to the Arm 5 to 6 compiler mitigation document
I cant find the solution to this in there.