Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

Błąd kompilacji na nowej bibliotece boost

Ostatnio zmodyfikowano 2021-06-05 13:17
Autor Wiadomość
Creativess
Temat założony przez niniejszego użytkownika
» 2021-06-05 12:41:04
Z tego wszystkiego to zapomniałem że task ma operator w osobnym pliku
tasks.h
z tego powodu wywaliło:
tasks.h:72:7: error: redefinition of ‘class Task’
 class Task{
       ^~~~
C/C++
//////////////////////////////////////////////////////////////////////
// OpenTibia - an opensource roleplaying game
//////////////////////////////////////////////////////////////////////
// Special Tasks which require more arguments than possible
// with STL functions...
//////////////////////////////////////////////////////////////////////
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//////////////////////////////////////////////////////////////////////


#ifndef __OTSERV_TASKS_H__
#define __OTSERV_TASKS_H__


#include <boost/function.hpp>
#include <functional>
#include "game.h"

/*
#include "player.h"
#include "position.h"


//class MovePlayer : public std::binary_function<Game*, Direction, int>{
class MovePlayerTask : public boost::function<bool(Game*, Direction)>{
public:
 MovePlayerTask(Player* player, Game* game, Direction dir) :
  //boost::function2<bool, Game*, Direction>(game, dir),
  _player(player)
 {
  _player->useThing2();
 }

 virtual ~MovePlayerTask()
 {
  _player->releaseThing2();
 }

 //virtual bool operator()(Game* game, Direction dir)
 result_type operator()(const first_argument_type& game, const second_argument_type& dir) const
 {
  OTSYS_THREAD_LOCK_CLASS lockClass(game->gameLock, "MovePlayerTask");

  if(_player->isRemoved()){
   return false;
  }

  //_player->lastMove = OTSYS_TIME();
  ReturnValue ret = game->internalMoveCreature(_player, dir);

  game->flushSendBuffers();

  return (ret == RET_NOERROR);
 }

private:
 Player* _player;
};*/

class Task {
public:
   
Task( boost::function1 < bool, Game * > f )
        :
_f( f )
   
{
       
//
   
}
   
   
virtual ~Task()
   
{
       
//
   
}
   
   
virtual void operator()( Game * arg )
   
{
       
_f( arg );
   
}
   
protected:
   
boost::function1 < bool, Game * > _f;
};

#endif

P-178711
DejaVu
» 2021-06-05 12:45:19
No to zadbaj o to, aby był on w jednym miejscu. Być może w tym pliku powinieneś mieć po prostu:
C/C++
//#include "game.h" <- wykomentuj tą linijkę i wstaw poniższą linijke:
class Game;

//... tu reszta Twojego kodu

Potem dołącz wszędzie plik task, gdzie potrzebujesz taska:
C/C++
#include "task.h"
P-178712
pekfos
» 2021-06-05 12:48:57
Ten plik jest zabezpieczony przed dwukrotnym dołączeniem, więc gdzieś w kodzie musi być jakaś śmieciowa definicja. W komunikacie błędu są podane lokalizacje obu, ale nie ma co się za dużo spodziewać po logu podanym przez użytkownika.
P-178713
Creativess
Temat założony przez niniejszego użytkownika
» 2021-06-05 13:10:05
Po dodaniu
class Game;
 w
tasks.h
 I fixie od pekfos, kompilacja przeszła, przepaszam Pekfos za brak rozgarnięcia z tym logiem, jak mogę namierzyć tą deklaracje zbędna która określiłeś jako śmieciowa?
P-178714
pekfos
» 2021-06-05 13:17:14
jak mogę namierzyć tą deklaracje zbędna która określiłeś jako śmieciowa?
Powinieneś mieć lokalizację w komunikacie błędu. Przykładowo
a.cpp:5:7: error: redefinition of 'class Task'
    5 | class Task
      |       ^~~~
a.cpp:1:7: note: previous definition of 'class Task'
    1 | class Task
      |       ^~~~
P-178715
1 « 2 »
Poprzednia strona Strona 2 z 2