C ++ compiler error "has not been declared in this area"

I get a strange compiler error when trying to compile a C ++ UDP client program.

g ++ -o client Udp.cpp ClientMain.c -I. -lpthread

In the file included in ClientMain.c: 1: 0:

Udp.h: In the destructor 'CUdpMsg :: ~ CUdpMsg ():

Udp.h: 103: 43: error: 'free has not been declared in this area

Udp.h: In the member function 'void CUdpMsg :: Add (in_addr_t, const void *, size_t):

Udp.h: 109: 34: error: 'malloc has not been declared in this area

Udp.h: 109: 41: error: "memcpy was not declared in this area

ClientMain.c: In the function 'int main (int, char **):

ClientMain.c: 28: 57: error: "memcpy was not declared in this area

ClientMain.c: 29: 61: error: 'printf was not declared in this area

ClientMain.c: 30: 17: : 'stdout

ClientMain.c: 30: 23: error: 'fflush

ClientMain.c: 34: 68: : 'printf

ClientMain.c: 35: 17: error: 'stdout

ClientMain.c: 35: 23: error: 'fflush

ClientMain.c: 37: 30: : "usleep

cpp.

#include <netinet/in.h>
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <cstdlib> 
#include <string>
#include <stdlib.h>
#include <cstring>

#include <errno.h>

, memcpy, string.h... ( cstring) , . - , ? .

+5
4

, . , , ?

+4

Udp.h . , cstring cstdlib , C- std::, .

+5

Mark B . , C cpp (#include <cHEADER> vs #include <HEADER.h>).

#include <cHEADER> std:: namespace. #include <HEADER.h> . , std::malloc(), ::strncpy(). , , .

, , . , .

header/cpp, , cpp, , . , , .cpp . , .

+5

, , CUdpMsg::~CUdpMsg udp.h udp.cpp, , . , (, getters).

0
source

All Articles