I was working on this project about 6 months ago. It was a windows 10 box and I was using Visual Studio 2017 Community. The project compiled fine. I decided to start working on it again but I have a new computer. Still a windows 10 box and still using VS Community 2017. Except this time when I go to build I'm getting hundreds of errors. This file for example has
E1696 cannot open source file "sys/socket.h"
E1696 cannot open source file "netinet/in.h"
E1696 cannot open source file "unistd.h"
E1696 cannot open source file "netdb.h"
E1696 cannot open source file "arpa/inet.h"
I get 271 errors in all. The path is obviously different on this new box than it was on the old one. Could that be the problem? What am I missing?
#ifndef SOCKETLIBTYPES_H
#define SOCKETLIBTYPES_H
// ==================================================================================================================
// Include Files.
// ==================================================================================================================
#ifdef WIN32 // Windows 95 and above
#include "winsock2.h" // Almost everything is contained in one file.
#include "Ws2tcpip.h"
#ifndef socklen_t
typedefint socklen_t;
#endif
#else // UNIX/Linux
#include <sys/types.h> // Header containing all basic data types and typedefs.
#include <sys/socket.h> // Header containing socket data types and functions.
#include <netinet/in.h> // IPv4 and IPv6 stuff.
#include <unistd.h> // For gethostname()
#include <netdb.h> // For DNS - gethostbyname()
#include <arpa/inet.h> // Contains all inet_* functions.
#include <errno.h> // Contains the error functions.
#include <fcntl.h> // File control.
#endif
namespace SocketLib
{
// =============================================================================================================
// Globals and Typedefs.
// =============================================================================================================
#ifdef WIN32 // Windows 95 and above
typedef SOCKET sock; // Although sockets are int's on Unix, windows uses it's own typedef of SOCKET to represent
// them. If you look in the Winsock2 source code, you'll see that it is just a typedef for
// int, but there is absolutely no guarantee that it won't change in a later version.
// Therefore, in order to avoid confusion, this library will create it's own basic socket
// descriptor typedef
#else // UNIX/Linux
typedefint sock; // See the description above.
#endif
// =============================================================================================================
// Ports will be in host byte order, but IP addresses in network byte order. It's easier this way; ports are
// usually accessed as numbers, but IP addresses are better accessed through the string functions.
// =============================================================================================================
typedefunsignedshortint port; // Define the port type.
typedefunsignedlongint ipaddress; // An IP address for IPv4
} // End namespace SocketLib
#endif
Has so much changed in just 6 months? As I said this worked fine on the same setup not that long ago.
I tried your suggestion. That helped the errors related to that specific error but now I'm getting
C4430 missing type specifier - int assumed. Note: C++ does not support default-int
Every instance of sint64 is an error in the code below. From my research it says that it's always stated as an error but can be turned off with #pragma warning. I'd rather know how to fix it though.
#ifndef BASICLIBTIME_H
#define BASICLIBTIME_H
#include "BasicLibTypes.h"
#include <string>
namespace BasicLib
{
// ================================================================================================================
// These functions get a time value. The Actual meaning of this time is undefined; it is only meant to be relative.
// ================================================================================================================
sint64 GetTimeMS();
sint64 GetTimeS();
sint64 GetTimeM();
sint64 GetTimeH();
// ================================================================================================================
// This prints a timestamp in 24 hours hh:mm:ss format.
// ================================================================================================================
std::string TimeStamp();
// ================================================================================================================
// This prints a datestamp in YYYY:MM:DD format.
// ================================================================================================================
std::string DateStamp();
// ================================================================================================================
// The Timer Class.
// ================================================================================================================
class Timer
{
public:
Timer();
void Reset(sint64 p_timepassed = 0);
sint64 GetMS();
sint64 GetS();
sint64 GetM();
sint64 GetH();
sint64 GetD();
sint64 GetY();
std::string GetString();
protected:
// This is the system time at which the timer was initialized.
sint64 m_inittime;
// This is the official "starting time" of the timer.
sint64 m_starttime;
};
inline sint64 seconds(sint64 t) { return t * 1000; }
inline sint64 minutes(sint64 t) { return t * 60 * 1000; }
inline sint64 hours(sint64 t) { return t * 60 * 60 * 1000; }
inline sint64 days(sint64 t) { return t * 24 * 60 * 60 * 1000; }
inline sint64 weeks(sint64 t) { return t * 7 * 24 * 60 * 60 * 1000; }
inline sint64 years(sint64 t) { return t * 365 * 24 * 60 * 60 * 1000; }
} // End namespace BasicLib
#endif
Maybe WIN32 is defined elsewhere, in which case there's an include-order dependency. Or maybe the docs are wrong. MSDN doesn't have a great track record IMO.
Edit: that's to @Thomas1965: I didn't refresh the page until now - one minute...
@mbozzi BasicLibTypes.h is listed below. Once I changed the WIN32 to _WIN32 as you stated in your first answer (I should've checked all the other files for that same string) that fixed ALL the errors and it compiles fine now.