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

This used to work in C51

I'm porting code from an 8051 to ARM. I have a string that shows Model, Version, Compile Date & Time:

#define ModelName "H"
#define FW_Version "1.04"
...
const char ModuleInfo[] = {"M2P " ModelName " v" FW_Version " " __DATE__ " @ " __TIME__};
...
printf("%s\r\n", ModuleInfo);

This would print: "M2P H v1.04 May 08 2007 @ 14:57:00". The ARM compiler now gives me error #67: expected a "}" for the const line. If the Date & Time macros are no longer valid, that's fine, but what else changed to prevent the rest from working? Or was C51 just more lenient? I added commas between all the fields and that didn't help.
Thanks.

Parents
  • Should compile ok unless you have managed to add some invalid character somewhere.

    You can not use any comma since you do not initialize an array of arrays of characters or array of character pointers. The compiler will glue together all string sections.

    Note that there is no need for the {} around the initialization.

Reply
  • Should compile ok unless you have managed to add some invalid character somewhere.

    You can not use any comma since you do not initialize an array of arrays of characters or array of character pointers. The compiler will glue together all string sections.

    Note that there is no need for the {} around the initialization.

Children