From 26427fa2578abbad758eb8eff80902af8172a592 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Wed, 14 Feb 2024 18:32:01 -0500 Subject: [PATCH] Added include guards to header files --- includes/base-helpers.hpp | 3 +++ includes/client.hpp | 10 +++++++--- includes/connect-helpers.hpp | 5 ++++- includes/math-helpers.hpp | 3 +++ includes/server.hpp | 6 +++++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/includes/base-helpers.hpp b/includes/base-helpers.hpp index 64c7be1..1c79dfd 100644 --- a/includes/base-helpers.hpp +++ b/includes/base-helpers.hpp @@ -1,3 +1,5 @@ +#ifndef _BASE_HELP +#define _BASE_HELP #include #include #include @@ -46,3 +48,4 @@ std::string base_convert(std::string num, int from_base, int to_base) { return result; } +#endif diff --git a/includes/client.hpp b/includes/client.hpp index a47a1f1..0b173f3 100644 --- a/includes/client.hpp +++ b/includes/client.hpp @@ -1,7 +1,10 @@ -#include "sock.hpp" +#ifndef _CLIENT_H +#define _CLIENT_H + +#include "includes/sock.hpp" +#include "includes/exception_consts.hpp" /* -Client class - Defines a TCP/UDP client. -- The constructor takes in a **remote** address and port, and connects the client to that address/port. +Client class - Inherits from 'Sock' class - Defines a TCP/UDP client. The only method that is overriden is the 'create_socket' method. */ class Client : public Sock { @@ -25,3 +28,4 @@ public: /* TODO - Add comments to better explain the inheritance and polymorphism going on */ }; +#endif diff --git a/includes/connect-helpers.hpp b/includes/connect-helpers.hpp index 595e2a3..3e8d7e5 100644 --- a/includes/connect-helpers.hpp +++ b/includes/connect-helpers.hpp @@ -1,10 +1,12 @@ +#ifndef _CONNECT_HELP +#define _CONNECT_HELP #include #include #include #include #include #include -#include +#include "includes/base-helpers.hpp" namespace connect_code { namespace { /* Since these are internal function, I have wrapped them in an anonymous namespace, to prevent outside access to them */ @@ -84,3 +86,4 @@ namespace connect_code { } } +#endif diff --git a/includes/math-helpers.hpp b/includes/math-helpers.hpp index beeda4f..b65b183 100644 --- a/includes/math-helpers.hpp +++ b/includes/math-helpers.hpp @@ -1,5 +1,8 @@ +#ifndef _MATH_HELP +#define _MATH_HELP int signum(int num) { int retval = 0; (num > 0) ? retval = 1 : retval = -1; return retval; } +#endif diff --git a/includes/server.hpp b/includes/server.hpp index 72c0556..517a1ab 100644 --- a/includes/server.hpp +++ b/includes/server.hpp @@ -1,4 +1,7 @@ -#include "sock.hpp" +#ifndef _SERVER +#define _SERVER +#include "includes/sock.hpp" +#include "includes/exception_consts.hpp" /* Server class - Defines a TCP/UDP server. @@ -26,3 +29,4 @@ public: /* TODO - Add comments to better explain the inheritance and polymorphism going on */ }; +#endif