c - C & libconfig: config_lookup_bool 返回 CONFIG_FALSE
问题描述
我正在尝试从一组中读取布尔设置。我正在使用以下代码,但config_lookup_bool
总是返回 CONFIG_FALSE。据我了解,它应该将值写入send_keys
并返回 CONFIG_TRUE 。
代码:
int send_keys;
config_t cfg;
config_init(&cfg);
config_read_file(&cfg, "config.cfg")
if (config_lookup_bool(&cfg, "settings.send_keys", &send_keys))
{
// do something here
}
配置文件:
settings :
{
send_keys = "true";
start_apps = "false";
sync_clocks = "false";
pc_clock_is_origin = "true";
calibration_start_time = 0L;
};
我的代码或我的想法有什么错误吗?
解决方案
感谢您的输入。问题是我在“”中有真/假,因此它被解析为字符串。应该是
settings :
{
send_keys = true;
start_apps = false;
sync_clocks = false;
pc_clock_is_origin = true;
calibration_start_time = 0L;
};
推荐阅读
- reverse-proxy - 带有位置指令的反向代理
- ruby - 没有 Rails 的 IRB 控制台中的 Figaro?
- angular - 在 Angular 4 中下载图像
- azure-eventgrid - 为 Azure 函数创建 EvenGridSubscription 时尝试验证提供的端点失败
- javascript - 无法访问正确的“this”
- javascript - 功能单击在右键单击 li 元素上不起作用
- javascript - node.js 错误:ENOENT:没有这样的文件或目录-使用本地模块时
- azure-ad-b2c - 使用高级设置手动配置 Azure Active Directory B2C
- java - log4j2:父记录器级别低于子记录器
- c# - 如果本地数据库已在应用程序第一次运行时播种,则拉异步不起作用