Форум программистов, компьютерный форум, киберфорум
С++ для начинающих
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.91/11: Рейтинг темы: голосов - 11, средняя оценка - 4.91
3 / 3 / 0
Регистрация: 02.01.2013
Сообщений: 116

Code Blocks ошибка

27.03.2014, 19:52. Показов 2301. Ответов 5
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
/usr/include/c++/4.7/type_traits|1857| required from ‘class std::result_of<std::_Mem_fn<void (TftpServer::*)()>(TftpServer)>’|


что это значит?
0
Programming
Эксперт
39485 / 9562 / 3019
Регистрация: 12.04.2006
Сообщений: 41,671
Блог
27.03.2014, 19:52
Ответы с готовыми решениями:

Code Blocks ошибка
Помогите разобраться, почему программа выдает ошибку.

Code::Blocks+template ошибка
#ifndef BTREE_H_INCLUDED #define BTREE_H_INCLUDED template&lt;class T&gt; class btree { public: ...

ошибка компиляции Code::Blocks 12.11
Доброго времени суток. Установил Code::Blocks 12.11. до этого пользовалься десятой версией. проблема в том, что компиляция не проходит,...

5
19497 / 10102 / 2461
Регистрация: 30.01.2014
Сообщений: 17,808
27.03.2014, 19:59
Pein95, может быть код приведешь? Просто телепаты сейчас на корпоративе.
0
3 / 3 / 0
Регистрация: 02.01.2013
Сообщений: 116
27.03.2014, 20:10  [ТС]
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#include "TftpServer.h"
#include <thread>
 
TftpServer::TftpServer() {
}
 
TftpServer::~TftpServer() {
 
 
 
}
 
 
void TftpServer::Start() {
  server_.Start(SIZEQUEUE);
  int index_thread = 0;
 
  while(index_thread < SIZEQUEUE) {
    if (server_.WaitConnection()) {
      cout << "... Client " << index_thread << " connected\n";
      TftpServer server = *this;
      arr_thread_[index_thread] = new std::thread(&TftpServer::ChooseAction, server);
      index_thread++;
    }
  }
 
  for (int i=0; i<index_thread-1; i++) {
    arr_thread_[i]->join();
  }
 
}
 
void TftpServer::ChooseAction() {
  string rmessage;
  string smessage;
  bool exit = false;
  while(true) {
    if (!RecvMessage(rmessage)) {
      cout << "... CLIENT DISCONNECT\n";
      break;
    }
 
    std::vector<std::string> request_param;
    int count_param = ParseRequest(rmessage, request_param);
    if(count_param == 0) {
      cout << "... ERROR COMMAND\n";
      break;
    }
 
    cout << ">>> " << rmessage << endl;
    //get code command
    int code_command = std::stoi(request_param[0]);
    switch (code_command)
    {
      //client want download file
      case GET: {
        //check second parameters in request
        //if  it did not exist
        if (request_param.size() < 2) {
          cout << "... UNKNOWN FILE NAME\n";
 
          //send message to client about error
          smessage += GetCodeCommandStr(ERROR);
 
          //server_.SendData(smessage);
          if (!SendMessage(smessage)) {
            cout << "... CLIENT DISCONNECT\n";
          }
 
          break;
        }
 
        //send message about successful or error and after that send file
        else {
          if (!SendFile(request_param[1])) {
            cout << "... ERROR SEND FILE\n";
          }
          break;
       }
 
      }
      //client want to upload file
      case PUT: {
        //check second parameters in request
        if (request_param.size() < 2) {
          cout << "... UNKNOWN FILE NAME\n";
           //send message to client about error
          smessage += GetCodeCommandStr(ERROR);
          if(!SendMessage(smessage)) {
            cout << "... CLIENT DISCONNECT\n";
          }
          break;
        }
 
        //send message about successful or error and after that upload file
        else {
          if (!RecvFile(request_param[1])) {
            cout <<"... ERROR RECEIVING FILE\n";
 
          }
          break;
      }
      case EXIT: {
        cout << "... Client disconnect\n";
        exit = true;
      }
      default:
        break;
      }
    }
    if (exit) {
      break;
    }
    rmessage = "";
    smessage = "";
  }
 
}
 
 
bool TftpServer::SendMessage(string message) {
  return server_.SendData(message);
}
 
bool TftpServer::RecvMessage(string &message) {
  server_.RecvData(message);
  return message.length();
}
 
bool TftpServer::SendFile(string file_name) {
  ifstream file;
  string smess;
  string rmess;
 
  file.open(file_name);
  if (!file.is_open()) {
    cout << "FILE NOT OPENED\n";
    smess = GetCodeCommandStr(ERROR);
    if (!SendMessage(smess)) {
      cout << "... CLIENT DISCONNECT\n";
 
    }
    return false;
  }
  else {
    smess = GetCodeCommandStr(SUCCESSFUL);
    if (!SendMessage(smess)) {
      cout << "... CLIENT DISCONNECT\n";
      return false;
    }
  }
 
  //receive
  if (!RecvMessage(rmess)) {
    cout << "... CLIENT DISCONNECT\n";
    return false;
  }
 
  if (std::stoi(rmess) == SUCCESSFUL) {
    if (!server_.SendFile(&file)) {
      cout << "... CLIENT DISCONNECT\n";
      return false;
    }
    return true;
  }
  return true;
 
}
 
 
bool TftpServer::RecvFile(string file_name) {
 
 string smess;
  string rmess;
  ofstream file;
 
 
  if (!RecvMessage(rmess)) {
    cout << "... CLIENT DISCONNECT\n";
    return false;
  }
 
  if (std::stoi(rmess) == SUCCESSFUL) {
    file.open(file_name);
 
    if (file.is_open()) {
      smess = GetCodeCommandStr(SUCCESSFUL);
      if (!SendMessage(smess)) {
        cout << "... CLIENT DISCONNECT\n";
        return false;
      }
    }
    else {
      smess = GetCodeCommandStr(ERROR);
      if (!SendMessage(smess)) {
        cout << "... CLEINT DISCONNECT\n";
        return false;
      }
      return false;
    }
 
    //receive file
    if (!server_.RecvFile(&file)) {
      cout << "... CLIENT DISCONNECT\n";
      return false;
    }
 
    return true;
 
  }
  return true;
 
}
гдето здесь.


вот весь лог make
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
g++ -std=c++11 -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o Source.o Source.cpp
g++ -std=c++11 -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o TftpClient.o TftpClient.cpp
TftpClient.cpp: In member function ‘bool TftpClient::RecvFile(std::string)’:
TftpClient.cpp:167:1: warning: control reaches end of non-void function [-Wreturn-type]
TftpClient.cpp: In member function ‘bool TftpClient::SendFile(std::string)’:
TftpClient.cpp:124:1: warning: control reaches end of non-void function [-Wreturn-type]
g++ -std=c++11 -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o TftpServer.o TftpServer.cpp
In file included from /usr/include/c++/4.7/bits/move.h:57:0,
                 from /usr/include/c++/4.7/bits/stl_pair.h:61,
                 from /usr/include/c++/4.7/bits/stl_algobase.h:65,
                 from /usr/include/c++/4.7/bits/char_traits.h:41,
                 from /usr/include/c++/4.7/string:42,
                 from TftpClass.h:4,
                 from TftpServer.h:5,
                 from TftpServer.cpp:1:
/usr/include/c++/4.7/type_traits: In instantiation of ‘struct std::_Result_of_impl<false, false, std::_Mem_fn<void (TftpServer::*)()>, TftpServer>’:
/usr/include/c++/4.7/type_traits:1857:12:   required from ‘class std::result_of<std::_Mem_fn<void (TftpServer::*)()>(TftpServer)>’
/usr/include/c++/4.7/functional:1563:61:   required from ‘struct std::_Bind_simple<std::_Mem_fn<void (TftpServer::*)()>(TftpServer)>’
/usr/include/c++/4.7/thread:133:9:   required from ‘std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (TftpServer::*)(); _Args = {TftpServer&}]’
TftpServer.cpp:22:84:   required from here
/usr/include/c++/4.7/type_traits:1834:9: error: no match for call to ‘(std::_Mem_fn<void (TftpServer::*)()>) (TftpServer)’
In file included from /usr/include/c++/4.7/bits/stl_algo.h:68:0,
                 from /usr/include/c++/4.7/algorithm:63,
                 from TftpClass.h:7,
                 from TftpServer.h:5,
                 from TftpServer.cpp:1:
/usr/include/c++/4.7/functional:525:11: note: candidates are:
/usr/include/c++/4.7/functional:548:7: note: _Res std::_Mem_fn<_Res (_Class::*)(_ArgTypes ...)>::operator()(_Class&, _ArgTypes ...) const [with _Res = void; _Class = TftpServer; _ArgTypes = {}]
/usr/include/c++/4.7/functional:548:7: note:   no known conversion for argument 1 from ‘TftpServer’ to ‘TftpServer&’
/usr/include/c++/4.7/functional:553:7: note: _Res std::_Mem_fn<_Res (_Class::*)(_ArgTypes ...)>::operator()(_Class*, _ArgTypes ...) const [with _Res = void; _Class = TftpServer; _ArgTypes = {}]
/usr/include/c++/4.7/functional:553:7: note:   no known conversion for argument 1 from ‘TftpServer’ to ‘TftpServer*’
/usr/include/c++/4.7/functional:559:2: note: _Res std::_Mem_fn<_Res (_Class::*)(_ArgTypes ...)>::operator()(_Tp&, _ArgTypes ...) const [with _Tp = TftpServer; _Res = void; _Class = TftpServer; _ArgTypes = {}]
/usr/include/c++/4.7/functional:559:2: note:   no known conversion for argument 1 from ‘TftpServer’ to ‘TftpServer&’
0
19497 / 10102 / 2461
Регистрация: 30.01.2014
Сообщений: 17,808
27.03.2014, 20:21
Ошибка здесь.
Цитата Сообщение от Pein95 Посмотреть сообщение
C++
1
2
3
TftpServer server = *this;
arr_thread_[index_thread] = new std::thread(&TftpServer::ChooseAction, server);
index_thread++;
Нельзя просто так передать указатель на метод, нужно забиндить ему указатель на объект (например this), чтобы его можно было вызвать. Например так:
C++
1
std::thread(std::bind(&TftpServer::ChooseAction, this));
Еще не очень понятно зачем передавать в поток временный объект server.
0
3 / 3 / 0
Регистрация: 02.01.2013
Сообщений: 116
27.03.2014, 20:30  [ТС]
в MS VS 2012 компилировалось.
это исправил.
но тут новая ошибка
/usr/include/x86_64-linux-gnu/c++/4.7/./bits/c++config.h|171|error: expected initializer before ‘namespace’|
0
19497 / 10102 / 2461
Регистрация: 30.01.2014
Сообщений: 17,808
27.03.2014, 20:38
Цитата Сообщение от Pein95 Посмотреть сообщение
/usr/include/x86_64-linux-gnu/c++/4.7/./bits/c++config.h|171|error: expected initializer before ‘namespace’|
Опять мне угадывать? Давай код с проблемой

Добавлено через 2 минуты
Попробую угадать все же. Не подключил #include <functional>?
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
inter-admin
Эксперт
29715 / 6470 / 2152
Регистрация: 06.03.2009
Сообщений: 28,500
Блог
27.03.2014, 20:38
Помогаю со студенческими работами здесь

Ошибка библиотеки graphics.h в Code::Blocks
Всем привет! Я работаю в CodeBlock когда пишу #include&lt;graphics.h&gt; все время выдает ошибку. Подскажите пожалуйста в чем дело!

Code::Blocks 13.12 и Lua = ошибка lua_open
Привет, подскажите в чем проблема: этот код работает нормально: #include &lt;iostream&gt; extern &quot;C&quot; { #include...

Ошибка в dev компиляторе, но в Code::Blocks нормально
ошибка в dev компиляторе , но в codeblocks нормально #include &lt;stdlib.h&gt; #include &lt;iostream&gt; using namespace std; const int...

Подсчет среднего арифметического элементов массива (ошибка в Code::Blocks)
Нужно составить программу считающую среднее арифметическое массива. Ошибка Process returned -1073741571 (0xC00000FD) #include...

Idle code blocks ошибка Target uses an invalid compiler; run aborted
idle code blocks помогите ошибка Target uses an invalid compiler; run aborted


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
6
Ответ Создать тему
Новые блоги и статьи
SDL3 для Web (WebAssembly): Работа со звуком через SDL3_mixer
8Observer8 08.02.2026
Содержание блога Пошагово создадим проект для загрузки звукового файла и воспроизведения звука с помощью библиотеки SDL3_mixer. Звук будет воспроизводиться по клику мышки по холсту на Desktop и по. . .
SDL3 для Web (WebAssembly): Основы отладки веб-приложений на SDL3 по USB и Wi-Fi, запущенных в браузере мобильных устройств
8Observer8 07.02.2026
Содержание блога Браузер Chrome имеет средства для отладки мобильных веб-приложений по USB. В этой пошаговой инструкции ограничимся работой с консолью. Вывод в консоль - это часть процесса. . .
SDL3 для Web (WebAssembly): Обработчик клика мыши в браузере ПК и касания экрана в браузере на мобильном устройстве
8Observer8 02.02.2026
Содержание блога Для начала пошагово создадим рабочий пример для подготовки к экспериментам в браузере ПК и в браузере мобильного устройства. Потом напишем обработчик клика мыши и обработчик. . .
Философия технологии
iceja 01.02.2026
На мой взгляд у человека в технических проектах остается роль генерального директора. Все остальное нейронки делают уже лучше человека. Они не могут нести предпринимательские риски, не могут. . .
SDL3 для Web (WebAssembly): Вывод текста со шрифтом TTF с помощью SDL3_ttf
8Observer8 01.02.2026
Содержание блога В этой пошаговой инструкции создадим с нуля веб-приложение, которое выводит текст в окне браузера. Запустим на Android на локальном сервере. Загрузим Release на бесплатный. . .
SDL3 для Web (WebAssembly): Сборка C/C++ проекта из консоли
8Observer8 30.01.2026
Содержание блога Если вы откроете примеры для начинающих на официальном репозитории SDL3 в папке: examples, то вы увидите, что все примеры используют следующие четыре обязательные функции, а. . .
SDL3 для Web (WebAssembly): Установка Emscripten SDK (emsdk) и CMake для сборки C и C++ приложений в Wasm
8Observer8 30.01.2026
Содержание блога Для того чтобы скачать Emscripten SDK (emsdk) необходимо сначало скачать и уставить Git: Install for Windows. Следуйте стандартной процедуре установки Git через установщик. . . .
SDL3 для Android: Подключение Box2D v3, физика и отрисовка коллайдеров
8Observer8 29.01.2026
Содержание блога Box2D - это библиотека для 2D физики для анимаций и игр. С её помощью можно определять были ли коллизии между конкретными объектами. Версия v3 была полностью переписана на Си, в. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru