C++ C++;文件中包含两种或更多数据类型

C++ C++;文件中包含两种或更多数据类型,c++,compiler-errors,header-files,C++,Compiler Errors,Header Files,我正在尝试处理我以前从未遇到过的问题 我尝试了这个链接,但对我没有好处。 我试图从类似的问题中寻找可能的解决方法,但这并没有帮助我解决自己的问题 我重新排序并做了分号,但我仍然得到了恼人的错误 处理文件中包含的错误: g++ -Wall -Wextra -c clock.cpp clock_main.cpp In file included from /usr/include/machine/_types.h:34, from /usr/include/sys/_typ

我正在尝试处理我以前从未遇到过的问题

我尝试了这个链接,但对我没有好处。 我试图从类似的问题中寻找可能的解决方法,但这并没有帮助我解决自己的问题

我重新排序并做了分号,但我仍然得到了恼人的错误

处理文件中包含的错误:

g++ -Wall -Wextra -c clock.cpp clock_main.cpp In file included from /usr/include/machine/_types.h:34,
             from /usr/include/sys/_types.h:33,
             from /usr/include/_types.h:27,
             from /usr/include/unistd.h:71,
             from /usr/include/c++/4.2.1/i686-apple-darwin10/x86_64/bits/os_defines.h:61,
             from /usr/include/c++/4.2.1/i686-apple-darwin10/x86_64/bits/c++config.h:41,
             from /usr/include/c++/4.2.1/iostream:44,
             from clock.cpp:2:
/usr/include/i386/_types.h:37: error: two or more data types in declaration of ‘__int8_t’
In file included from /usr/include/machine/_types.h:34,
             from /usr/include/sys/_types.h:33,
             from /usr/include/_types.h:27,
             from /usr/include/unistd.h:71,
             from /usr/include/c++/4.2.1/i686-apple-darwin10/x86_64/bits/os_defines.h:61,
             from /usr/include/c++/4.2.1/i686-apple-darwin10/x86_64/bits/c++config.h:41,
             from /usr/include/c++/4.2.1/iostream:44,
             from clock_main.cpp:2:
/usr/include/i386/_types.h:37: error: two or more data types in declaration of ‘__int8_t’
以及一些导致错误的文件

clock_main.cpp

#include "clock.h"
#include <iostream> // line 2 cause of error by compiler
using namespace std;


int main(){
  Clock clk_0 (86399); // 1 day - 1 sec
  cout << "initial time" << endl;
  clk_0.print_time();
  ++clk_0;
  cout << "adding one second" << endl;
  clk_0.print_time();
  --clk_0;
  cout << "subtracting one second" << endl;
  clk_0.print_time();


  return 0;
}
/* 我们制作了一个简单的时钟类 我们使用重载操作符的能力

*/

clock.cpp

#include "clock.h"
#include <iostream> // the offending line

inline Clock::Clock(unsigned int i){ 
  tot_secs = i;
  secs = tot_secs % 60; 
  mins = (tot_secs / 60) % 60; 
  hours = (tot_secs / 3600) % 24; 
  days = tot_secs / 86400;
};

void Clock::tick(){
  Clock temp = Clock (++tot_secs);
  secs = temp.secs;
  mins = temp.mins;
  hours = temp.hours;
  days = temp.days;
}

void Clock::tock(){
  Clock temp = Clock (--tot_secs);
  secs = temp.secs;
  mins = temp.mins;
  hours = temp.hours;
  days = temp.days;
}

void Clock::print_time() const{
  std::cout << days << " days: " << hours << " hours: " << mins <<
  " minutes: " << secs << " seconds" << std::endl;
}
#包括“clock.h”
#包括//
内联时钟::时钟(无符号整数i){
tot_secs=i;
秒=总秒数%60;
分钟=(总秒/60)%60;
小时=(总秒/3600)%24;
天数=tot_secs/86400;
};
void Clock::tick(){
时钟温度=时钟(++总秒);
秒=温度秒;
分钟=温度分钟;
小时=临时小时;
天数=临时天数;
}
void Clock::tock(){
时钟温度=时钟(-tot_secs);
秒=温度秒;
分钟=温度分钟;
小时=临时小时;
天数=临时天数;
}
无效时钟::打印时间()常量{
std::cout分号

class Clock{
  public:
    Clock (unsigned int i); // construct and conversion
    void print_time() const; //formatted printout
    void tick(); // add one second
    void tock(); // subtract one second
    Clock operator++() {tick(); return *this;}
    Clock operator--() {tock(); return *this;}
    ~Clock() {}; 
  private:
    unsigned long tot_secs, secs, mins, hours, days;
}  ;
// ^^
分号

class Clock{
  public:
    Clock (unsigned int i); // construct and conversion
    void print_time() const; //formatted printout
    void tick(); // add one second
    void tock(); // subtract one second
    Clock operator++() {tick(); return *this;}
    Clock operator--() {tock(); return *this;}
    ~Clock() {}; 
  private:
    unsigned long tot_secs, secs, mins, hours, days;
}  ;
// ^^

谢谢,我必须记住声明定义类需要分号,否则将导致不明确的头文件错误。:P谢谢,我必须记住声明定义类需要分号,否则将导致不明确的头文件错误。:P
class Clock{
  public:
    Clock (unsigned int i); // construct and conversion
    void print_time() const; //formatted printout
    void tick(); // add one second
    void tock(); // subtract one second
    Clock operator++() {tick(); return *this;}
    Clock operator--() {tock(); return *this;}
    ~Clock() {}; 
  private:
    unsigned long tot_secs, secs, mins, hours, days;
}  ;
// ^^