Thread: #endif Header Guard not closing

  1. #1
    Registered User
    Join Date
    Apr 2017
    Posts
    7

    #endif Header Guard not closing

    I've written a header file containing all of my file declarations for a program, but according to my code editor, Atom the #endif guard is not closing properly. The problem seems to be with two non-member operator overloads that are at the end of my .h file, but I feel like everything is where it should be so I'm not sure why the #endif guard is not closing. Here's my code:
    Code:
    #ifndef SICT_DATE_H__
    #define SICT_DATE_H__
    
    
    //readErrorCode_ definitions
    #define NO_ERROR 0 //no error date if valid
    #define CIN_FAILED 1 //istream failed when entering information
    #define YEAR_ERROR 2 //year value is invalid
    #define MON_ERROR 3 //month value is invalid
    #define DAY_ERROR 4 //day value is invalid
    
    
    namespace sict {
    
    
    class Date {
      int year_; //holds year; a four digit int between MIN_YEAR and MAX_YEAR
      int mon_; //month of the year, between 1 to 12
      int day_; //day of the month, not that a leap year in February is 29 days, (see mday())
      int readErrorCode_; //holds an error code with which the caller program can reference
      //to find out if the date value is valid and if not, which part is erroneous.
      int value() const; //function already implemented
      void errCode(int errorCode); //sets the readErrorCode_ member variable to one of
      //the values mentioned above
      void isValid(); //determine is date values are within range
      //Constructors
    public:
      Date(); //default constructor: sets year_, mon_ and day_ to "0" and readErrorCode_ to NO_ERROR
      Date(int year, int month, int day); //three argument constructor: accepts three arguments to set values
      //of year_, mon_ and day_ attributes. Also sets readErrorCode_ to NO_ERROR
    
    
      //comparison logical operator overloads
      bool operator==(const Date& D)const;
      bool operator!=(const Date& D)const;
      bool operator<(const Date& D)const;
      bool operator>(const Date& D)const;
      bool operator<=(const Date& D)const;
      bool operator>=(const Date& D)const;
    
    
      int mdays(int mon)const; //function is already implemented and provided
    
    
      //accessor or getter member functions
      int errCode()const; //returns readErrorCode_ value
      bool bad()const; //returns true if readErrorCode_ is not equal to zero
    
    
      //IO member functions
      std::istream& read(std::istream& istr);//reads date in the following format: YYY?MM?DD
      std::ostream& write(std::ostream& ostr)const;
    };
      //writes the date using ostr argument in the following format
      //YYY/MM/DD then return the ostr
      std::ostream& operator<<(std::ostream& os, const Date& D);
      std::istream& operator>>(std::istream& is, Date& D);
    }
    #endif

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,738
    > but according to my code editor, Atom the #endif guard is not closing properly.
    The final arbiter is the compiler.
    Perhaps the more likely explanation is your editor is borked.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Including source file twice, but with include guard
    By thetinman in forum C Programming
    Replies: 4
    Last Post: 06-15-2014, 01:53 PM
  2. inclusion guard help
    By romerboy55 in forum C++ Programming
    Replies: 3
    Last Post: 09-02-2006, 12:39 AM
  3. #endif *
    By dwks in forum C Programming
    Replies: 9
    Last Post: 10-13-2005, 06:53 AM
  4. #endif ?
    By Zahl in forum C++ Programming
    Replies: 7
    Last Post: 11-12-2002, 12:20 PM
  5. #if and #endif
    By Arthuro in forum C Programming
    Replies: 1
    Last Post: 09-30-2002, 09:49 AM

Tags for this Thread