I want to migrate an older project into the ARM Compiler 6, but I am getting errors in the retarget.c
/* Short version of retarget.c - Minimum code to support simple printf in Keil MDK-ARM */ /**************************************************************/ /* Minimum retarget functions for ARM DS-5 Professional / Keil MDK */ /**************************************************************/ #pragma import(__use_no_semihosting_swi) #include <lpc17xx.h> #include <stdio.h> struct __FILE { int handle; /* Add whatever you need here */ }; FILE __stdout; FILE __stdin; FILE __stderr; int fputc(int ch, FILE *f) { return (ITM_SendChar(ch)); } void _sys_exit(int return_code) { label: goto label; /* endless loop */ }
retarget.c(7): error: '#pragma import' is an ARM Compiler 5 extension, and is not supported by ARM Compiler 6 [-Warmcc-pragma-import] #pragma import(__use_no_semihosting_swi) ^ retarget.c(10): error: redefinition of '__FILE' struct __FILE { int handle; /* Add whatever you need here */ }; ^ C:\Keil_v5\ARM\ARMCLANG\Bin\..\include\stdio.h(119): note: previous definition is here struct __FILE { ^ 2 errors generated.
When I read in the documentation I find a retarget_io.c. Can I just take that one instead and delete the old retarget.c?
So I deleted the retarget.c and now my program breaks during debugging without having set a breakpoint before.
Change the line to
__asm(".global __use_no_semihosting");
It works, but I think I can also safely delete the file and set the Run-Time Environment -> Compiler -> I/O -> TTY, STDOUT, STDIN and STDERR to ITM
Change the line to __asm(".global __use_no_semihosting");
After do this,
retarget.c(7): error: '#pragma import' is an ARM Compiler 5 extension, and is not supported by ARM Compiler 6 [-Warmcc-pragma-import]#pragma import(__use_no_semihosting_swi)
above error disappeared,but the following error still exists:
retarget.c(10): error: redefinition of '__FILE'struct __FILE { int handle; /* Add whatever you need here */ };
how to deal with it?
From the error message, I suspect you need to either not include stdio.h from that file, or remove the redefinition.