你好我有以下问题:
- IDE:Eclipse 版本:2018-12 (4.10.0),带有 Keil C51 插件(用于语言映射)
- 编译器(外部):Wickenhäuser uc51
这里的问题:Eclipse Bad Character Sequence
Keil 语言映射使用以下语法:
xdata unsigned char Port = 0x1;
Wickenhäuser 略有不同:
xdata unsigned char Port @ 0x1;
所以我来到了这个工作解决方案:
#ifdef __CDT_PARSER__
xdata unsigned char Port = 0x1;
#else
//xdata unsigned char Port @ 0x1; //BAD Character Squence encountered: @
#define AT_ADDRESS(n) @##n //Using this Macro to get around this problem
xdata unsigned char Port_B AT_ADDRESS(0x1);
#endif
但是这个解决方案并不完美,(双写等)应该是这样的:
#ifdef __CDT_PARSER__ //In Keil I have to define this too, to make use the Keil syntax
//#define AT_ADDRESS(n) // This works
#define AT_ADDRESS(n) =##n // Gives error
#else
#define AT_ADDRESS(n) @##n
#endif
xdata unsigned char Port_B AT_ADDRESS(0x1); // GIVES ERROR: Invalid use of macro pasting in macro AT_ADDRESS
不幸的是 Eclipse 标记了这一点:在宏 AT_ADDRESS 中使用宏粘贴无效