转移到ubuntu 18.04后无法建立扭矩

时间:2018-05-11 14:45:37

标签: gcc g++ torque ubuntu-18.04

安装ubuntu 18.04后,我无法构建扭矩软件。 Ubuntu 16.04没有出现这样的错误。

make[4]: Entering directory '/home/socrates/torque-6.1.2/src/lib/Libattr'
g++ -DHAVE_CONFIG_H -I. -I../../../src/include  -I../../../src/include
`xml2-config --cflags` -Wno-implicit-fallthrough -std=gnu++11  
-g -fstack-protector -Wformat -Wformat-security -DFORTIFY_SOURCE=2
-W -Wall -Wextra -Wno-unused-parameter -Wno-long-long -Wpedantic -Werror -Wno-sign-compare
-MT req.o -MD -MP -MF .deps/req.Tpo -c -o req.o req.cpp  

req.cpp: In member function ‘int req::set_from_submission_string(char*, std::__cxx11::string&)’:  
req.cpp:1057:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]  

    else if (current != '\0')

                        ^~~~  
Makefile:521: recipe for target 'req.o' failed  
make[4]: *** [req.o] Error 1  

1 个答案:

答案 0 :(得分:2)

如果参数-std未指定另一个C ++较新版本,则默认情况下,Ubuntu 16.04中的g ++是C ++ 03编译器。 默认情况下,Ubuntu 18.04中的g ++是C ++ 14编译器,指针与int(从char '\0'强制转换)的比较无效。

我认为代码if (current != '\0') current是一个指针是可疑的,也许这是一个错误。它应该是

if (*current != '\0')

或者

if (current != 0)  // before C++11
if (current != nullptr) // since C++11
if (current) // for both before and since C++11

如果没有上下文(MCVE),则必须决定是否必须使用current*current

<强>更新

我查看了扭矩-6.1.2代码。肯定有一个错误。

char       *current;
// ...
this->task_count = strtol(submission_str, &current, 10);
//...
if (*current == ':')
  current++;
else if (current != '\0') // BUG is here, it must be (*current != '\0')
  {
  error = "Invalid task specification";
  return(PBSE_BAD_PARAMETER);
  }