小编Cod*_*110的帖子

如何在cmake项目中使用tclap

我是 tclap 和 cmake 的新手

  1. 为什么安装前需要配置tclap?我认为它只是由头文件组成?

  2. 我如何将 tclap 库包含在 cmake 项目中。我不能将头文件复制到 lib 目录或其他目录中(并根据需要修改 CMakeLists)吗?

我对这一切感到摸不着头脑。顺便说一句,我发现这个包含 tclap,看起来作者正在使用 cmake。我可以复制 cmake 相关文件并稍微修改一下吗?在这种情况下,我认为 cmake 启动 tclaps 自己的配置过程是否正确?

请帮帮我。

cross-platform autotools cmake getopt

5
推荐指数
1
解决办法
2102
查看次数

如何修复整数溢出警告

我有一些代码检查整数是否在[?2 ^ 31 + 1,2 ^ 31?1]。但是,在编译期间,将引发整数溢出警告。

long int tmp_l = strtol(tokens[8].c_str(),NULL,10);

if (tmp_l >= ( (int32_t)-1 * ( ((int32_t)1<<31) - (int32_t)1) ) && 
        tmp_l <= ( ((int32_t)1 << 31) - (int32_t)1) ) {

    long int in_range = tmp_l;

} else {
    cerr << "ERROR: int not in range. Expected [(-2^31)-1, (2^31)-1]. ";
    cerr << "Found: " << tmp_l << endl;
}
Run Code Online (Sandbox Code Playgroud)
main.cpp:93:51: warning: integer overflow in expression [-Woverflow]
     if (tmp_l >= ((int32_t)-1 * (((int32_t)1<<31) - (int32_t)1) ) &&
                                  ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ …
Run Code Online (Sandbox Code Playgroud)

c++ integer-overflow

0
推荐指数
1
解决办法
86
查看次数