Skip to content

Commit

Permalink
fix for gcc10 with MSYS2
Browse files Browse the repository at this point in the history
attempting to copy apparently private changes at
graphstream#9

changed Makefile to detect Windows using $(OS) instead of uname.
  • Loading branch information
jdpipe committed Nov 24, 2021
1 parent b730eab commit 3bf6868
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 78 deletions.
6 changes: 6 additions & 0 deletions c++/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
netstream-main
*.exe
*.dll
*.so
*.o
*.a
3 changes: 2 additions & 1 deletion c++/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ CDBG = -g $(CWARN) -fno-inline
CFLAGS = -I$(INCDIR) -O3
DFLAGS = -I$(INCDIR) -g $(CWARN) -fno-inline -DDEBUG=1

ifeq ($(shell uname),MINGW32_NT-6.1)
# https://stackoverflow.com/questions/714100/os-detecting-makefile
ifeq ($(OS),Windows_NT)
SOCKET_LIB = -lwsock32
else
SOCKET_LIB =
Expand Down
6 changes: 3 additions & 3 deletions c++/src/netstream-sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ void NetStreamSender::init()
std::cout<<"."<<std::flush;
wait_for_server++;
#ifdef WIN32
Sleep(ms);
Sleep(1); //milliseconds
#else
usleep(1000);
usleep(1000);//microseconds
#endif
}
}
Expand Down Expand Up @@ -304,4 +304,4 @@ void NetStreamSender::removeEdgeAttribute(const string & source_id, long time_id
event.writeString(attribute);
_sendEvent(event);
}
}
}
12 changes: 2 additions & 10 deletions c++/src/netstream-socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ namespace netstream
void
NetStreamSocket::
BailOnNetStreamSocketError( std::string context)
const throw( NetStreamSocketException )
const
{
#ifdef WIN32
int e = WSAGetLastError();
Expand All @@ -166,7 +166,7 @@ namespace netstream
bool
NetStreamSocket::
datawaiting(int sock)
const throw()
const
{
fd_set fds;
FD_ZERO( &fds );
Expand Down Expand Up @@ -217,7 +217,6 @@ namespace netstream
void
NetStreamSocket::
accept()
throw( NetStreamSocketException )
{
if( socket_ >= 0 )
return;
Expand Down Expand Up @@ -282,7 +281,6 @@ namespace netstream
void
NetStreamSocket::
set_blocking(bool blocking)
throw(NetStreamSocketException )
{
blocking_ = blocking;

Expand Down Expand Up @@ -310,7 +308,6 @@ namespace netstream
void
NetStreamSocket::
connect()
throw( NetStreamSocketException )
{
in_addr addr;
if( !atoaddr( host_.c_str(), addr) )
Expand Down Expand Up @@ -359,7 +356,6 @@ namespace netstream
void
NetStreamSocket::
send( std::vector<unsigned char> b)
throw( NetStreamSocketException )
{
if( socket_ < 0 ) return;

Expand Down Expand Up @@ -411,7 +407,6 @@ namespace netstream
void
NetStreamSocket::
sendExact( const NetStreamStorage &b)
throw( NetStreamSocketException )
{
int length = static_cast<int>(b.size());
NetStreamStorage length_storage;
Expand All @@ -428,7 +423,6 @@ namespace netstream
vector<unsigned char>
NetStreamSocket::
receive(int bufSize)
throw( NetStreamSocketException )
{
vector<unsigned char> b;

Expand Down Expand Up @@ -474,7 +468,6 @@ namespace netstream
bool
NetStreamSocket::
receiveExact( NetStreamStorage &msg )
throw( NetStreamSocketException )
{
/* receive length of vector */
unsigned char * const bufLength = new unsigned char[4];
Expand Down Expand Up @@ -552,7 +545,6 @@ namespace netstream
bool
NetStreamSocket::
is_blocking()
throw()
{
return blocking_;
}
Expand Down
26 changes: 13 additions & 13 deletions c++/src/netstream-socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ namespace netstream
private:
std::string what_;
public:
NetStreamSocketException( std::string what ) throw()
NetStreamSocketException( std::string what )
{
what_ = what;
//std::cerr << "netstream::NetStreamSocketException: " << what << std::endl << std::flush;
}

virtual const char* what() const throw()
virtual const char* what() const noexcept
{
return what_.c_str();
}

~NetStreamSocketException() throw() {}
~NetStreamSocketException() {}
};

class NetStreamSocket
Expand All @@ -76,18 +76,18 @@ namespace netstream
~NetStreamSocket();

/// Connects to host_:port_
void connect() throw( NetStreamSocketException );
void connect();

/// Wait for a incoming connection to port_
void accept() throw( NetStreamSocketException );
void send( const std::vector<unsigned char> ) throw( NetStreamSocketException );
void sendExact( const NetStreamStorage & ) throw( NetStreamSocketException );
std::vector<unsigned char> receive( int bufSize = 2048 ) throw( NetStreamSocketException );
bool receiveExact( NetStreamStorage &) throw( NetStreamSocketException );
void accept();
void send( const std::vector<unsigned char> ) ;
void sendExact( const NetStreamStorage & ) ;
std::vector<unsigned char> receive( int bufSize = 2048 ) ;
bool receiveExact( NetStreamStorage &) ;
void close();
int port();
void set_blocking(bool) throw( NetStreamSocketException );
bool is_blocking() throw();
void set_blocking(bool) ;
bool is_blocking() ;
bool has_client_connection() const;

// If verbose, each send and received data is written to stderr
Expand All @@ -96,12 +96,12 @@ namespace netstream

private:
void init();
void BailOnNetStreamSocketError( std::string ) const throw( NetStreamSocketException );
void BailOnNetStreamSocketError( std::string ) const ;
#ifdef WIN32
std::string GetWinsockErrorString(int err) const;
#endif
bool atoaddr(std::string, struct in_addr& addr);
bool datawaiting(int sock) const throw();
bool datawaiting(int sock) const ;

std::string host_;
int port_;
Expand Down
Loading

0 comments on commit 3bf6868

Please sign in to comment.