开源改变世界

无法使用新的俄语翻译编译 Marlin #271

推推 grbl 2年前 (2023-02-05) 175次浏览
关闭
VasilyStepanov 打开了这个问题 2012 年 10 月 16 日 · 10 条评论
关闭

无法使用新的俄语翻译编译 Marlin#271

VasilyStepanov 打开了这个问题 2012 年 10 月 16 日 · 10 条评论

评论

无法使用新的俄语翻译编译 Marlin #271

问题

LiquidCrystalRus.cpp:16:9: error: ‘prog_uchar’ does not name a type
LiquidCrystalRus.cpp: In member function ‘virtual size_t LiquidCrystalRus::write(uint8_t)’:
LiquidCrystalRus.cpp:307:14: error: ‘utf_recode’ was not declared in this scope

发生这种情况是因为 avr/pgmspace.h 中的“prog_uchar”定义。
在我的 avr 版本中(Gentoo 4.7.2 p1.1,pie-0.5.5)prog_uchar typedef-ed 是这样的:

#elif defined(__PROG_TYPES_COMPAT__)  /* !DOXYGEN */
// ...
typedef unsigned char prog_uchar __attribute__((__progmem__,deprecated("prog_uchar type is deprecated.")));
// ...
#endif

__PROG_TYPES_COMPAT__描述为:

/**
   \ingroup avr_pgmspace
   \typedef prog_uchar
   \note DEPRECATED

   This typedef is now deprecated because the usage of the __progmem__ 
   attribute on a type is not supported in GCC. However, the use of the 
   __progmem__ attribute on a variable declaration is supported, and this is 
   now the recommended usage.

   The typedef is only visible if the macro __PROG_TYPES_COMPAT__
   has been defined before including <avr/pgmspace.h> (either by a
   #define directive, or by a -D compiler option.)

   Type of an "unsigned char" object located in flash ROM.
*/

这一切都意味着使用 prog_uchar 类型根本就不太好。

解决方法

diff --git a/Marlin/LiquidCrystalRus.cpp b/Marlin/LiquidCrystalRus.cpp
index 66bb370..9f3f5c0 100644
--- a/Marlin/LiquidCrystalRus.cpp
+++ b/Marlin/LiquidCrystalRus.cpp
@@ -1,3 +1,4 @@
+#define __PROG_TYPES_COMPAT__
 #include "LiquidCrystalRus.h"

 #include <stdio.h>
@@ -13,7 +14,7 @@

 // it is a russian alphabet translation
 // except 0401 --> 0xa2 = ╗, 0451 --> 0xb5
-PROGMEM prog_uchar utf_recode[] = 
+const PROGMEM prog_uchar utf_recode[] = 
        { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f,
          0xa8,0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1,
          0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f,
无法使用新的俄语翻译编译 Marlin #271
贡献者

谢谢瓦西里。老实说,我还是不喜欢这个“翻译”,因为它不是真正的翻译。翻译应该向现有集合添加另一种语言,而不是添加仅语言不同的文件的另一个版本。
LiquidCrystalRus.c 和 LiquidCrystalRus.h 不应存在。所有翻译和功能(如果需要)都应该在语言标题中,然后在 LiquidCrystal.c 和 LiquidCrystal.h 中加载/使用

所以也许让我们退后一步并正确地做……

无法使用新的俄语翻译编译 Marlin #271

好吧,伙计们,如果你知道如何正确制作集成包 git://github.com/mk90/LiquidCrystalRus.git,那就去做吧。
我准备成为一名测试员。

无法使用新的俄语翻译编译 Marlin #271

也许这会解决这个问题?
机器人世界/LiquidCrystalRus@ 58b4534

无法使用新的俄语翻译编译 Marlin #271
贡献者

👎
Grrr ….为什么我们坚持只为俄语准备一个单独的文件的想法?让我们将所有内容放入 LiquidCrystal.c 而不是创建 LiquidCrystalRus.c :/

无法使用新的俄语翻译编译 Marlin #271

LiquidCrystal.c 是 Arduino 的一部分……

无法使用新的俄语翻译编译 Marlin #271

和本机实现 LiquidCrystal 不支持俄语字符:(

无法使用新的俄语翻译编译 Marlin #271

瓦西里,把你的电话写在邮件里,我们住在同一个城市,会讨论得更快。

无法使用新的俄语翻译编译 Marlin #271

从我的角度来看,解决方案应该如下:必须将多语言支持直接添加到 arduino 代码树中。

另一方面,由于 LiquidCrystalRus 代码已经合并,因此有必要以某种方式修复它以使其在现代环境中可编译(例如 avr-4.7.2、avr-libc-1.8.0)。不幸的是我根本没有 LCD,所以最好由其他人来完成 :) 但解决方案或多或少是清楚的: setar 建议的RoboCraft/LiquidCrystalRus@ 58b4534看起来不错。

setar,其实我们已经认识了,你应该知道我的手机。我至少有你的 ;)
我不知道我们还能通过电话讨论什么。但你可以把你的 LCD 给我,这样我就能修好所有这些东西。

无法使用新的俄语翻译编译 Marlin #271
贡献者

永远不要使用 prog_* typedef,它们会做一些新的 gcc 版本不支持的事情。因为它之前已经有一个 PROGMEM,所以也不需要 prog_* 类型。请注意,我已在 Marlin 源代码中对此进行了更改。所以你可以再次测试。

(我还做了一些其他更改,使使用较新的 avr-gcc 版本进行编译更容易,因为不再有包含代码的 pde 文件)