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.
Hi,
I use Keil MicroVision (v. 5.11.1.0) for programming a Cortex-M4 microcontroller from TI.
After migrating my project from StellarisWare to TivaWare I get compiler errors for nearly equal line of code, which contains a line break.
For me it doesn't seem TI specific, so I post it here in the Keil forum.
Here is an example error:
compiling ustdlib.c... ..\..\TivaWareM4C\utils/ustdlib.h(55): error: #18: expected a ")" extern int usnprintf(char * restrict s, size_t n, const char * restrict format,
The related source lines are these:
extern int usnprintf(char * restrict s, size_t n, const char * restrict format, ...);
I'm not shure, why TI added a line break and what's the meaning of "...". I don't want to modify this file (and others) of the TivaWare package, because this can cause a coders hell.
.
What's strange?
StellarisWare (the predecessor of TivaWare) also contains a file "ustdlib.c", which also has definitions with line breaks. But compiling this causes no error.
In direct comparison:
Line in "ustdlib.c" of StellarisWare:
extern int usnprintf(char *pcBuf, unsigned long ulSize, const char *pcString, ...);
Line in "ustdlib.c" of TivaWare:
The same compiler error happens to other lines, which contains a line break. Example:
extern float ustrtof(const char * restrict nptr, const char ** restrict endptr);
Why I get such compiler errors after my migration to TivaWare? Also before the migration I included the file "ustdlib.c" (including such wrapped lines) and had no errors.
If you need further information, just tell me.
The construct:
#ifdef __cplusplus extern "C" { #endif
will only make sure that a C++ compiler will correctly follow the C standard for external symbol names when linking, so that the C++ program can access C functions available in object files or libraries.
The above construct does not take into account syntactic changes between C and C++, such as differences in reserved keywords etc.
So using a C++ compiler that doesn't support "restricted" you would need:
#ifdef __cplusplus #define restricted #endif
to make sure that your C compiler sees the keyword and your C++ compiler doesn't see it.