如何使用德语语言环境在gdb中设置双变量

How to set a double variable in gdb with German locale?

本文关键字:设置 变量 gdb 何使用 德语 语言 环境      更新时间:2023-10-16

我正在用gdb调试我的c++程序。由于德语环境的原因,我很难设置一个简单的double变量。

gdb不会接受带小数点的值。gdb使用德语小数点(逗号)键入,忽略逗号后的所有内容。

(gdb) p this->foodSupply
$1 = 1
(gdb) set this->foodSupply = 4.3
Ungültige Nummer »4.3«.
(gdb) p this->foodSupply
$1 = 1
(gdb) set this->foodSupply = 4,3
(gdb) p this->foodSupply 
$3 = 4

我想我可以通过使用LC_ALL=EN gdb ...运行gdb来避免这个问题。但由于在IDE中工作并不容易,我想知道是否还有其他方法。

德国用户如何在gdb中键入小数点?

看看这个bug:
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1341125
也许可以解释一下,为什么它不能像你希望的那样工作。

你可以尝试像这样的变通方法

(gdb) set this->foodSupply = (double) 43/10  

如果你的数字像4.3那么简单。