您好,我遇到以下问题:
问题在这里:Eclipse错误字符序列
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中无效使用了宏粘贴
答案 0 :(得分:2)
您现在不需要粘贴。只需替换
#define AT_ADDRESS(n) =##n
作者
#define AT_ADDRESS(n) = n
扩展C版本也是如此,在您显示的两个“扩展”示例中,地址符号和实际地址之间都插入了一个空格字符,因此:
#ifdef __CDT_PARSER__ //In Keil I have to define this too, to make use the Keil syntax
#define AT_ADDRESS(n) = n
#else
#define AT_ADDRESS(n) @ n
#endif
答案 1 :(得分:0)
现在,我构建了经过改进的(具有上述提示)有效的解决方案。
#ifndef COMPILER_COMPAT_H_
#define COMPILER_COMPAT_H_
#define COMPILER_COMPAT_WICKEN // Comment out for use project in Keil
#ifdef __CDT_PARSER__
# undef COMPILER_COMPAT_WICKEN
#endif
#ifndef COMPILER_COMPAT_WICKEN
# ifndef BIT_ADDRESS
# define BIT_ADDRESS(n) = n
# endif
#else
# ifndef BIT_ADDRESS
# define BIT_ADDRESS(n) @ n
# endif
#endif
#endif /* COMPILER_COMPAT_H_ */