2017-04-10 84 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的頂部可能會使代碼的那部分被編譯...但是可能有更多的問題不僅僅是這種情況。

相關問題