2017-04-10 83 views
0

我想编译这个项目Realtimebattle reloaded (github)错误:无法将'dirent *'转换为'search_directories(std :: string,std :: list <start_tournament_info_t *>&,bool):: direct *'

但GCC抛出奇怪的错误:

RealTimeBattle_reloaded/RealtimeBattle/original_gtk/src/Various.cc:473:30: error: cannot convert ‘dirent*’ to ‘search_directories(std::string, std::list<start_tournament_info_t*>&, bool)::direct*’ in assignment 
     while(NULL != (entry = readdir(dir))) 

和源代码是:

void 
search_directories(string directory, 
        list<start_tournament_info_t*>& tour_list, 
        const bool check_robots) 
{ 
    bool err_in_file = false; 
    DIR* dir; 
    if(NULL != (dir = opendir(directory.c_str()))) 
    { 
     struct dirent* entry; 
     while(NULL != (entry = readdir(dir))) 
     { 
      string full_file_name = directory + entry->d_name; 
      bool res = false; 
      if(check_robots) 
      res = check_if_filename_is_robot(full_file_name, &err_in_file); 
      else 
      res = check_if_filename_is_arena(full_file_name, &err_in_file); 
      if(res) 
      { 
       start_tournament_info_t* info; 
       info = new start_tournament_info_t(0, false, full_file_name, ""); 
       tour_list.push_back(info); 
      } 
     } 
     closedir(dir); 
    } 
} 

我很困惑与日志。

+0

您确定自己发布的代码和错误与您在本地看到的内容相符吗?你写了两次错误引用了'direct'而不是'dirent',但是你的发布代码没有使用前一种类型。这个错字是否存在于原始代码中?如果没有,请生成并发布[MCVE](http://stackoverflow.com/help/mcve)。 – jerry

回答

0

原始版本没有使用的CMake:https://github.com/ezag/realtimebattle

这可能是转移到CMake的构建系统不完整的端口。

这里发生了什么事是代码依赖于在编译期间定义的宏。

放置:'#define HAVE_DIRENT_H'位于Various.cc的顶部可能会使代码的那部分被编译...但是可能有更多的问题不仅仅是这种情况。

相关问题