0

今まで経験したことのない問題に対処しようとしています。

このリンクを試しましたが、うまくいきませんでした。 システム ヘッダー ファイル /usr/include/i386_types.h のエラー 同様の問題から考えられる解決策を探してみましたが、自分の問題を解決するのに役立ちませんでした。

並べ替えてセミコロンを実行しましたが、それでも迷惑なエラーが発生します

ファイルに含まれるエラーの処理:

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;
}

時計.h

#ifndef CLOCK_H
#define CLOCK_H

/* 単純なクロック クラスを作成し、演算子のオーバーロードの力を利用します

*/

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;
}

#endif

時計.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;
}
4

1 に答える 1

4

セミコロン

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;
}  ;
// ^^
于 2013-05-05T04:53:41.253 に答える