Table of Contents
Common G++ Errors
Summary
This is a guide to help you CS35ers make sense of g++ and its often cryptic error messages.
If you discover an error not listed here feel free to edit this wiki,
or send your error along with source code and an explanation to me — grawson1@swarthmore.edu
Weird Errors
If you are getting strange compiler errors when your syntax looks fine, it might be a good idea to check that your Makefile is up to date
and that you are including the proper .h files. Sometimes a missing } or ; or ) will yield some scary errors as well.
Lastly, save all files that you might have changed before compiling.
Bad Code Sample
What’s wrong with the following code? (Hint: there are two errors)
#include<iostream> using namespace std; int main(){ int foo; for(int i = 0, i<100, i++) { foo++; cout << foo << endl; } return 0; }
When compiled this yields:
junk.cpp:9: error: expected initializer before '<' token
junk.cpp:13: error: expected primary-expression before 'return
‘
junk.cpp:13: error: expected `;' before 'return
‘
junk.cpp:13: error: expected primary-expression before 'return
‘
junk.cpp:13: error: expected `)' before 'return
‘
First, the parameters of the for
loop need to be separated by semicolons, not commas.
for(int i = 0; i<100; i++) { foo++; cout << foo << endl; }
Now look at this sample output of the corrected code:
-1208637327
-1208637326
-1208637325
-1208637324
-1208637323
-1208637322
Why the weird values? Because we never initialized foo
before incrementing it.
int foo = 0;
‘cout’ was not declared in this scope
Two things to check here:
(1) Did you add
#include<iostream>
to your list of headers?
(2) Did you add
using namespace std;
after your #includes?
‘printf’ was not declared in this scope
Add
#include<cstdio>
to your list of headers. Note if you are coming from C programming, adding
#include<cstdio> is preferred in C++ over #include <stdio.h>.
Cannot Pass Objects of non-POD Type
junk.cpp:8: warning: cannot pass objects of non-POD type 'struct std::string' through '…'; call will abort at runtime
junk.cpp:8: warning: format '%s' expects type 'char*', but argument 2 has type 'int
‘
What this usually means is that you forgot to append .c_str() to the name of your string variable when using printf.
This error occurred when trying to compile the following code:
int main(){ string foo = "dog"; printf("This animal is a %s.n",foo); return 0; }
Simply appending to .c_str() to “foo” will fix this:
printf("This animal is a %s.n",foo.c_str());
The reason you got this error is because printf is a C function and C handles strings differently than C++
Invalid Use of Member
junk.cpp:8: error: invalid use of member (did you forget the '&' ?)
What this usually means is that you forget to add () to the end of a function call.
Ironically, every time I see this it is never because I forgot the ‘&’.
This error occurred when trying to compile the following code:
int main(){ string foo = "dog"; printf("This animal is a %s.n",foo.c_str); return 0; }
Simply adding the open and close parentheses () will take care of this for you:
printf("This animal is a %s.n",foo.c_str());
Request for Member ‘Foo’ in ‘Bar’, which is of non-class type ‘X’
trycredit.cpp:86: error: request for member 'print' in 'card', which is of non-class type 'CreditCard*
‘
What this usually means is that you are using a ‘.’ between the class pointer and the function you are trying to call.
Here is an example from the CreditCard lab:
void useCard(CreditCard *card, int method) { //Used to access the methods of the class if (method==1) { card.print(); }
Since card
is a CreditCard* we need → rather than . Fixed:
if (method==1) { card->print(); }
Undefined Reference to V Table
This error usually means you need to add a destructor to your myClass.cpp/myClass.inl code.
If you don’t want to implement a real destructor at this point, you can write something like this:
myClass::~myClass(){}
So long as the destructor exists, you should now be able to compile fine. Of course,
implement a real destructor at a later point.
asiniy 0 / 0 / 0 Регистрация: 29.02.2012 Сообщений: 8 |
|||||||||||||||||||||
1 |
|||||||||||||||||||||
29.02.2012, 20:40. Показов 8326. Ответов 21 Метки нет (Все метки)
Здравствуйте! Я — абсолютный новичок в программировании на C. Нашёл учебник Кернигана и Ричи. В нём — helloworld.
Я компилирую файл: cc HELLO.C HELLO.C:1:7: error: ISO C++ forbids declaration of ‘MAIN’ with no type Далее я копирую содеримое файла hello.C, найденного в интернете:
Компиляция проходит успешно. Однако дальше проблема. Учебник говорит мне: Прогон его по команде A.OUT я в sh ввожу a.out, однако результатов никаких. Просьба, во-первых, объяснить, что значат эти строки:
А также посоветуйте учебник по программированию. Спасибо, Александр
__________________
0 |
Заблокирован |
|||||||||||||||||
29.02.2012, 21:03 |
2 |
||||||||||||||||
Советую самый лучший учебник по программированию от создателей языка С Керниган и Ричи Добавлено через 4 минуты
Это заголовочный файл. Все вызываемые функции как например printf(); где-то хранятся. Компилятор не знает где, поэтому ему надо об этом сказать. При запуске данной программы ты на очень короткое время увидишь черный экран консоли который сразу иcчезнет.
Добавлено через 7 минут <удалено>
1 |
0 / 0 / 0 Регистрация: 29.02.2012 Сообщений: 8 |
|
29.02.2012, 21:16 [ТС] |
3 |
Советую самый лучший учебник по программированию от создателей языка С Керниган и Ричи Я его и использую; но там нет про include stdio.h и return 0; (который, кстати, и не нужен). И, да, void не работает. Работает int. При запуске данной программы ты на очень короткое время увидишь черный экран консоли который сразу иcчезнет. Я его не вижу вообще. Добавление getchar(); проблемы не решает
0 |
Заблокирован |
||||
29.02.2012, 21:30 |
4 |
|||
Для начала всегда соблюдай синтаксис. В этом коде ошибок нет.
Если он у тебя не компилится, значит проблема в чем-то другом.
1 |
Ruzal |
|
29.02.2012, 22:00 |
5 |
Здравствуйте! |
Заблокирован |
|
29.02.2012, 22:05 |
6 |
Во время изучения языка — все равно. Сразу С а потом С++
0 |
0 / 0 / 0 Регистрация: 29.02.2012 Сообщений: 8 |
|
29.02.2012, 22:07 [ТС] |
7 |
А теперь подробно расскажи на чем компилишь и как создаешь проект Через утилиту cc — в sh ввожу cc hello.c
0 |
Заблокирован |
|
29.02.2012, 22:10 |
8 |
Я так понимаю все на Линуксе делаешь, тогда помочь не могу обращайся к линуксистам.
0 |
0 / 0 / 0 Регистрация: 29.02.2012 Сообщений: 8 |
|
29.02.2012, 22:13 [ТС] |
9 |
Намёк на переход с соседнюю тему?
0 |
go 3645 / 1377 / 243 Регистрация: 16.04.2009 Сообщений: 4,526 |
||||
29.02.2012, 22:15 |
10 |
|||
В этом коде ошибок нет. Громко сказано. Совет: пишите все в нижнем регистре, т.к. в Си (в отличии от Паскаля, например) это разные вещи получатся. Добавлено через 1 минуту
1 |
Заблокирован |
|
29.02.2012, 22:16 |
11 |
go, Ты имеешь ввиду «N», дык это его печеньки, пусть грызет.
0 |
asiniy 0 / 0 / 0 Регистрация: 29.02.2012 Сообщений: 8 |
||||
29.02.2012, 22:17 [ТС] |
12 |
|||
go, спасибо, работает. Можете привести какой-нибудь учебник по c, где есть все нововведения, типа
0 |
0 / 0 / 0 Регистрация: 29.02.2012 Сообщений: 8 |
|
29.02.2012, 22:25 [ТС] |
14 |
Благодарю Ну пока хватит, потом может ещё что прочту. Я рубист вообще
0 |
Nameless One 5826 / 3477 / 358 Регистрация: 08.02.2010 Сообщений: 7,448 |
||||||||
01.03.2012, 07:06 |
15 |
|||||||
В этой программе есть одна ошибка пропущено слово void нет. Функция main по стандарту должна возвращать int. Если спецификатор возвращаемого значения пропущен, то считается, что функция по умолчания возвращает int
я в sh ввожу a.out, однако результатов никаких В Linux (в отличиет от Windows) поиск исполняемых файлов происходит только в директориях, указанных в $PATH. В текущей директории исполняемые файлы не ищутся, поэтому нужно при запуске явно указать путь к исполняемому файлу, абсолютный:
или относительный (если файл находится в текущей директории)
А вообще я бы посоветовал для сборки использовать Make-файлы Добавлено через 3 минуты
Можете привести какой-нибудь учебник по c, где есть все нововведения, типа этим нововведениям уже не один десяток лет. Просто ты используешь древнюю версию книги. На русском есть второе издание, выпущенное в 2009 г., там таких косяков нет
1 |
Заблокирован |
|
01.03.2012, 17:53 |
16 |
st НЕ НЕТ, а да. int должен возвращаться в С++, а в С должен возвращаться void (т.е. ничего) А автор ветки пишет пока что на С, вот и пусть пишет как надо в С.
0 |
5826 / 3477 / 358 Регистрация: 08.02.2010 Сообщений: 7,448 |
|
01.03.2012, 17:57 |
17 |
int должен возвращаться в С++, а в С должен возвращаться void (т.е. ничего) ой-ой-ой, как интересно. Может, ткнешь меня носом в раздел стандарта, где это написано? Или мне самому из него цитату привести?
Unix и DOS не нуждаются чтобы им возвращали какие-то значения, это только винда выклянчивает у каждой программы нолик. Иначе она коректно работать не может. Бред. Феерический.
0 |
Заблокирован |
|||||
01.03.2012, 17:58 |
18 |
||||
nix и DOS не нуждаются чтобы им возвращали какие-то значения, это только винда выклянчивает у каждой программы нолик. Иначе она коректно работать не может. Хам и зазнайка
0 |
5826 / 3477 / 358 Регистрация: 08.02.2010 Сообщений: 7,448 |
|
01.03.2012, 18:00 |
19 |
IFree Host, аргументы есть? Или скажешь, что я был не прав?
0 |
Заблокирован |
|||||
01.03.2012, 18:02 |
20 |
||||
Не, если быть до конца честным, то со стандартами еще не удосужился ознакомиться. А вообще говорю то, что нам проф выдает. А он мудлан еще тот. На кучу вопросов нет ответов.
0 |
- Forum
- The Ubuntu Forum Community
- Ubuntu Specialised Support
- Development & Programming
- Programming Talk
- error: ‘printf’ was not declared in this scope
-
error: ‘printf’ was not declared in this scope
Hi,
I want to try the code below and It is a code with preprocessors. I get an error.
Can anyone can tell me the reason?
Code:
#define HATALI(A) A*A*A /* Kup icin hatali makro */ #define KUP(A) (A)*(A)*(A) /* Dogusu ... */ #define KARE(A) (A)*(A) /* Karesi icin dogru makro */ #define START 1 #define STOP 9 main() { int i,offset; offset = 5; for (i = START;i <= STOP;i++) { printf("%3d in karesi %4d dir, ve kubu ise %6d dir..n", i+offset,KARE(i+offset),KUP(i+offset)); printf("%3d in HATALIsi ise %6d dir.n",i+offset,HATALI(i+offset)); } }
the error:
Code:
'printf' was not declared in this scope
-
Re: error: ‘printf’ was not declared in this scope
-
Re: error: ‘printf’ was not declared in this scope
WW ,
Thanks for helpwhen included the <studi> header file
it returned an error:
Code:
studio.h: No such file or directory
I am using gcc compiler. Can this be the reason?
-
Re: error: ‘printf’ was not declared in this scope
-
Re: error: ‘printf’ was not declared in this scope
WW,thanks.
I’m so inattentiveanyway, the program give a more garbled error…
what does this error mean?
how can I fix the problem?
Code:
/tmp/ccGQNcoh.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0' collect2: ld output returned 1
-
Re: error: ‘printf’ was not declared in this scope
What command did you use that results in that error?
-
Re: error: ‘printf’ was not declared in this scope
I’m using vi editor and first of all I created a file like this:
Code:
user@user-desktop:~$ vi example_macro.cpp
then I compiled the file by the command:
Code:
sh-3.1$ gcc example_macro.cpp -o objmacro
by the way I have a off topic question,
I have created a file:user@user-desktop:~$ mkdir make_file_work
then I go and look both the ‘user’ file and to the ‘desktop’ I cannot find such a directory? But if I write the command:
user@user-desktop:~$ cd make_file_work
I can go inside that file, but I cannot see it in the file browser…
why?
thanks again for your help WW…
-
Re: error: ‘printf’ was not declared in this scope
You appear to be writing C, not C++. Rename the file to example_macro.c, and try again. (I just tried it both ways; I got the same error that you did when the file was called example_macro.cpp, and it compiled fine when I called it example_macro.c.)
-
Re: error: ‘printf’ was not declared in this scope
It’ll compile as a .cpp if you put the line…
Code:
using namespace std;
under the include for stdio.h, or preface printf with «std::» in order to tell the compiler that you’re using a function from the standard namespace.
-
Re: error: ‘printf’ was not declared in this scope
Yes, it compiled when I changed the extesion from .cpp to .c. But I dont know the diferrences between the c and cpp.
Does the reason depends to ‘printf’ function? Because, as far as I remember I use cout function instead of printf in cpp. I guess printf is a c function…
But when I tried with
#include <stdio>
using namespace std;it gave an error again. the error the same:
Code:
/tmp/ccubDW3d.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0' collect2: ld output return 1
what does this error mean anyway?
«/tmp/ccubDW3d.o» :……………………………………what is the object ccubDW3d.o in the ‘tmp’ directory?
«(.eh_frame+0x11)» :………………………………….. can this be an address?
«undefined reference to `__gxx_personality_v0′» : it says ‘__gxx_personality_v0’ and says there is an undefined reference to this ‘thing’. But I’ve not use that thing in my . ………………………………………….. …………………..code. What does it refer to in my code?
«collect2: ld output return 1» : what is collect 2? What is ld output? What does returning 1 means?WW and Mime thanks for help
Last edited by ankakusu; June 3rd, 2007 at 11:10 AM.
Bookmarks
Bookmarks

Posting Permissions
Topic: ‘fprint’ was not declared in this scope| (Read 3462 times)
When I try to build I get the error below:
main.cpp|18|error: ‘fprint’ was not declared in this scope|
My code includes:
#include <stdio.h>
I found 3 files named stdio.h in the Code::Blocks directorys.
None of them have fprint in them.
I am using Code::Blocks 17.12 on Windows 8.1
Logged
I’m not going to live long enough to do all I want to do.
Logged
(most of the time I ignore long posts)
[strangers don’t send me private messages, I’ll ignore them; post a topic in the forum, but first read the rules!]
I don’t think it is appropriate for you to chastise me for not using search engines,
I searched and followed the links including stackoverflow and couldn’t find a solution.
Now, tell me, what was I supposed to find in that link you gave me that would solve my problem! I read it top to bottom three times.
I also did a ctrl-f on the page and searched it for «declared» and «scope» and neither words are on the page.
Big help you are!
Pete
Logged
I’m not going to live long enough to do all I want to do.
I’m afraid no one can help you. Not even Google. If you can’t see after reading the page three times that the function is called fprintf, maybe visit a doctor?
Logged
It was appropriate for you to be chastised, as you ignored the purpose of this forum as a resource for help using the IDE and not programming help in general. Keep practicing and you’ll learn to be able to solve these issues yourself.
Logged
Well, explain why this exact code compiles on my raspberry pi but not on Windows 8.1.
That is why I assumed it was something to do with codeblocks not the code.
Logged
I’m not going to live long enough to do all I want to do.
Well, explain why this exact code compiles on my raspberry pi but not on Windows 8.1.
That is why I assumed it was something to do with codeblocks not the code.
Learn the name and version of the Compiler being used on both systems.
Then, try building the code with the same mistyping on both systems.
NOTE: Code::Blocks is not an Compiler! Read the CB FAQs.
Tim S.
Logged
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
—
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org
СОДЕРЖАНИЕ ►
- Произошла ошибка при загрузке скетча в Ардуино
- programmer is not responding
- a function-definition is not allowed arduino ошибка
- expected initializer before ‘}’ token arduino ошибка
- ‘что-то’ was not declared in this scope arduino ошибка
- No such file or directory arduino ошибка
- Compilation error: Missing FQBN (Fully Qualified Board Name)
Ошибки компиляции Arduino IDE возникают при проверке или загрузке скетча в плату, если код программы содержит ошибки, компилятор не может найти библиотеки или переменные. На самом деле, сообщение об ошибке при загрузке скетча связано с невнимательностью самого программиста. Рассмотрим в этой статье все возможные ошибки компиляции для платы Ардуино UNO R3, NANO, MEGA и пути их решения.
Произошла ошибка при загрузке скетча Ардуино
Самые простые ошибки возникают у новичков, кто только начинает разбираться с языком программирования Ардуино и делает первые попытки загрузить скетч. Если вы не нашли решение своей проблемы в статье, то напишите свой вопрос в комментариях к этой записи и мы поможем решить вашу проблему с загрузкой (бесплатно!).
avrdude: stk500_recv(): programmer is not responding
Что делать в этом случае? Первым делом обратите внимание какую плату вы используете и к какому порту она подключена (смотри на скриншоте в правом нижнем углу). Необходимо сообщить Arduino IDE, какая плата используется и к какому порту она подключена. Если вы загружаете скетч в Ардуино Nano V3, но при этом в настройках указана плата Uno или Mega 2560, то вы увидите ошибку, как на скриншоте ниже.
Такая же ошибка будет возникать, если вы не укажите порт к которому подключена плата (это может быть любой COM-порт, кроме COM1). В обоих случаях вы получите сообщение — плата не отвечает (programmer is not responding). Для исправления ошибки надо на панели инструментов Arduino IDE в меню «Сервис» выбрать нужную плату и там же, через «Сервис» → «Последовательный порт» выбрать порт «COM7».
a function-definition is not allowed here before ‘{‘ token
Это значит, что в скетче вы забыли где-то закрыть фигурную скобку. Синтаксические ошибки IDE тоже распространены и связаны они просто с невнимательностью. Такие проблемы легко решаются, так как Arduino IDE даст вам подсказку, стараясь отметить номер строки, где обнаружена ошибка. На скриншоте видно, что строка с ошибкой подсвечена, а в нижнем левом углу приложения указан номер строки.
expected initializer before ‘}’ token / expected ‘;’ before ‘}’ token
Сообщение expected initializer before ‘}’ token говорит о том, что вы, наоборот где-то забыли открыть фигурную скобку. Arduino IDE даст вам подсказку, но если скетч довольно большой, то вам придется набраться терпения, чтобы найти неточность в коде. Ошибка при компиляции программы: expected ‘;’ before ‘}’ token говорит о том, что вы забыли поставить точку с запятой в конце командной строки.
‘что-то’ was not declared in this scope
Что за ошибка? Arduino IDE обнаружила в скетче слова, не являющиеся служебными или не были объявлены, как переменные. Например, вы забыли продекларировать переменную или задали переменную ‘DATA’, а затем по невнимательности используете ‘DAT’, которая не была продекларирована. Ошибка was not declared in this scope возникает при появлении в скетче случайных или лишних символов.
Например, на скриншоте выделено, что программист забыл продекларировать переменную ‘x’, а также неправильно написал функцию ‘analogRead’. Такая ошибка может возникнуть, если вы забудете поставить комментарий, написали функцию с ошибкой и т.д. Все ошибки также будут подсвечены, а при нескольких ошибках в скетче, сначала будет предложено исправить первую ошибку, расположенную выше.
exit status 1 ошибка компиляции для платы Arduino
Данная ошибка возникает, если вы подключаете в скетче библиотеку, которую не установили в папку libraries. Например, не установлена библиотека ИК приемника Ардуино: fatal error: IRremote.h: No such file or directory. Как исправить ошибку? Скачайте нужную библиотеку и распакуйте архив в папку C:Program FilesArduinolibraries. Если библиотека установлена, то попробуйте скачать и заменить библиотеку на новую.
Довольно часто у новичков выходит exit status 1 ошибка компиляции для платы arduino uno /genuino uno. Причин данного сообщения при загрузке скетча в плату Arduino Mega или Uno может быть огромное множество. Но все их легко исправить, достаточно внимательно перепроверить код программы. Если в этом обзоре вы не нашли решение своей проблемы, то напишите свой вопрос в комментариях к этой статье.
missing fqbn (fully qualified board name)
Ошибка возникает, если не была выбрана плата. Обратите внимание, что тип платы необходимо выбрать, даже если вы не загружаете, а, например, делаете компиляцию скетча. В Arduino IDE 2 вы можете использовать меню выбора:
— список плат, которые подключены и были идентифицированы Arduino IDE.
— или выбрать плату и порт вручную, без подключения микроконтроллера.
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <sys/socket.h>
#include <sys/unistd.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <netinet/in.h>
#include <signal.h>
#include <iostream>
#include <thread>
using namespace std;
#define BUFFSIZE 2048
#define DEFAULT_PORT 4001 //
#define MAXLINK 2048
void connecter()
{
printf("Listening...n");
while (true)
{
signal(SIGINT, stopServerRunning); //
//
connfd = accept(sockfd, NULL, NULL);
if (-1 == connfd)
{
printf("Accept error(%d): %sn", errno, strerror(errno));
return -1;
}
}
}
void listener()
{
while(true)
{
bzero(buff, BUFFSIZE);
//
recv(connfd, buff, BUFFSIZE - 1, 0);
//
printf("клиент: %sn", buff);
//
send(connfd, buff, strlen(buff), 0);
}
}
void sender()
{
while(true)
{
printf("Please input: ");
scanf("%s", buff);
send(connfd, buff, strlen(buff), 0);
bzero(buff, sizeof(buff));
recv(connfd, buff, BUFFSIZE - 1, 0);
printf("recv: %sn", buff);
}
}
int sockfd, connfd;
void stopServerRunning(int p)
{
close(sockfd);
printf("Close Servern");
exit(0);
}
int main()
{
struct sockaddr_in servaddr;
char buff[BUFFSIZE];
//
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (-1 == sockfd)
{
printf("Create socket error(%d): %sn", errno, strerror(errno));
return -1;
}
//
//
bzero(&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(DEFAULT_PORT);
if (-1 == bind(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr)))
{
printf("Bind error(%d): %sn", errno, strerror(errno));
return -1;
}
//
//
if (-1 == listen(sockfd, MAXLINK))
{
printf("Listen error(%d): %sn", errno, strerror(errno));
return -1;
}
while(true)
{
thread my_thread(connecter);
if(connfd == true)
break;
}
thread my_thread(connecter);
thread my_thread(listener);
thread my_thread(sender);
return 0;
}
}
это исходный код программы, хотел написать что-то вроде чата на сокетах. Я попытался скомпилировать код, но он мне выдал несколько ошибок «was not declared in this scope». Вот вывод компилятора:
server.cpp: In function ‘void connecter()’:
server.cpp:24:24: error: ‘stopServerRunning’ was not declared in this scope
24 | signal(SIGINT, stopServerRunning); // Это предложение используется для выключения сервера при вводе Ctrl + C
|
server.cpp:26:9: error: ‘connfd’ was not declared in this scope
26 | connfd = accept(sockfd, NULL, NULL);
| ^~~~~~
server.cpp:26:25: error: ‘sockfd’ was not declared in this scope; did you mean ‘socket’?
26 | connfd = accept(sockfd, NULL, NULL);
| ^~~~~~
| socket
server.cpp: In function ‘void listener()’:
server.cpp:39:15: error: ‘buff’ was not declared in this scope
39 | bzero(buff, BUFFSIZE);
| ^~~~
server.cpp:41:14: error: ‘connfd’ was not declared in this scope
41 | recv(connfd, buff, BUFFSIZE - 1, 0);
| ^~~~~~
server.cpp: In function ‘void sender()’:
server.cpp:54:21: error: ‘buff’ was not declared in this scope
54 | scanf("%s", buff);
| ^~~~
server.cpp:55:14: error: ‘connfd’ was not declared in this scope
55 | send(connfd, buff, strlen(buff), 0);
| ^~~~~~
я думаю, что все эти ошибки идут из одной проблемы, но не могу понять откуда