免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1371 | 回复: 6
打印 上一主题 下一主题

『求助』 gcc的一些问题。。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-04-25 22:48 |只看该作者 |倒序浏览
现在手头上有  一个 realtime.cc文件和realtime.hh文件
g++ -I./ -c realtime.cc
出来错误信息:(大概)
can not find  “new”  from  urs/include/c++/3.2
很多这样的linux的标准函数文件找不到。。可是它确实是在那个目录下面。。
不知怎么回事??
new:46:parse error before "{"
..........................
而且后面的错误里面居然会有上面这样的错误。。
不解,如果new文件没找到,,怎么会它的代码出语法错误??
求解。。谢!

下面是源代码。是从网上down的(是一个RTI的源代码。应该不会错吧)
real-time.cc,real-time.hh和real-time.icc是其中的几个文件

real-time.hh
//----------------------------------------------------------------------
// File:    time.hh
// Type:    header file
// Created: Wen. Jun 25, 1997
// Author:  Marc MOREAU
//
// Description: This file contains the declaration for the RealTime class
//

#ifndef REAL_TIME_HH
#define REAL_TIME_HH

// system include files
#include <sys/time.h>;
#include <iostream.h>;

// other include files
#include <mmsysdep.h>;

class RealTime {
public:
  RealTime();
  RealTime(const RealTime& t2);
  void setTime();
  void setTime(long s, long us);
  bool operator < (const RealTime& t2) const;
  bool operator == (const RealTime& t2) const;
  RealTime& operator += (const RealTime& t2);
  RealTime operator + (const RealTime& t2) const;
  RealTime operator - (const RealTime& t2) const;
  RealTime operator / (const int l) const;
  friend ostream& operator << (ostream& os, const RealTime& t2) ;
  RealTime const &operator= (const RealTime& t2);
  uint32 disTime();
private:
  struct timeval tp;
}; // class RealTime

typedef RealTime* RealTimePtr ;

#ifndef OUTLINE
#include <real-time.icc>;
#endif

#endif
//----------------------------------------------------------------------

real-time.icc
//----------------------------------------------------------------------
// File:    real-time.icc
// Type:    implementation file: inline calls
// Created: Fri. Jun 27, 1997
// Author:  Marc MOREAU
//
// Description: This file contains inline methods for the RealTime class
//


inline bool RealTime:perator < (const RealTime& t2) const
{
  return ((tp.tv_sec<t2.tp.tv_sec) || (tp.tv_sec==t2.tp.tv_sec && tp.tv_usec<t2.tp.tv_usec));
} // operator <

inline bool RealTime:perator == (const RealTime& t2) const
{
  return ((tp.tv_sec==t2.tp.tv_sec) && (tp.tv_usec==t2.tp.tv_usec));
} // operator ==


inline uint32 RealTime::disTime()
{
  uint32 t = tp.tv_sec*1000000+tp.tv_usec;
  return (((uint32)(((float64)(t % 3600000)) * (2147483647.0 / 3600000.0))) << 1);
} // RealTime::disTime
//--------------------------------------------------------------------


real-time.cc
//---------------------------------------------------------------------
// File:    real-time.cc
// Type:    implementation file
// Created: Wen. Jun 25, 1997
// Author:  Marc MOREAU
//
// Description: This file contains the implementations of the RealTime class
//

#include <real-time.hh>;

#ifdef OUTLINE
#define inline
#include <real-time.icc>;
#undef inline
#endif

RealTime::RealTime()
{
  tp.tv_sec  = 0;
  tp.tv_usec = 0;
} // RealTime::RealTime

RealTime::RealTime(const RealTime& t2)
{
  tp.tv_sec  = t2.tp.tv_sec;
  tp.tv_usec = t2.tp.tv_usec;
} // RealTime::RealTime

void RealTime::setTime()
{
  if (gettimeofday(&tp, NULL)<0)
    cerr << "gettimeofday failed" << endl;
  return ;
} // setTime

void RealTime::setTime(long s, long us) {
  tp.tv_sec  = s;
  tp.tv_usec = us;
} // setTime

RealTime& RealTime:perator += (const RealTime& t2)
{
  tp.tv_sec += t2.tp.tv_sec;
  tp.tv_usec += t2.tp.tv_usec;
  return *this;
} // operator +=

RealTime RealTime:perator + (const RealTime& t2) const
{
  RealTime result;
  result.tp.tv_sec = tp.tv_sec + t2.tp.tv_sec;
  result.tp.tv_usec = tp.tv_usec + t2.tp.tv_usec;
  return result;
} // operator +

RealTime RealTime:perator - (const RealTime& t2) const
{
  RealTime result;
  result.tp.tv_sec = tp.tv_sec - t2.tp.tv_sec;
  result.tp.tv_usec = tp.tv_usec - t2.tp.tv_usec;
  return result;
} // operator -

RealTime RealTime:perator / (const int l) const
{
  RealTime result;
  result.tp.tv_sec = tp.tv_sec/l;
  result.tp.tv_usec = tp.tv_usec/l;
  return result;
} // operator /
ostream& operator << (ostream& os, const RealTime& t2) {
  os << "(" << t2.tp.tv_sec << ", " << t2.tp.tv_usec << "";
  return os;
} // operator <<

RealTime const & RealTime:perator= (const RealTime& t2) {
  if (this != &t2) {
    tp.tv_sec  = t2.tp.tv_sec;
    tp.tv_usec = t2.tp.tv_usec;
  }
  return (*this);
} // operator=
//--------------------------------------------------------------------

论坛徽章:
0
2 [报告]
发表于 2003-04-25 22:57 |只看该作者

『求助』 gcc的一些问题。。

g++

论坛徽章:
0
3 [报告]
发表于 2003-04-26 12:22 |只看该作者

『求助』 gcc的一些问题。。

g++出来是一样一样一样的。

怎么回事?哪个大哥帮忙啊。。

论坛徽章:
0
4 [报告]
发表于 2003-04-26 12:30 |只看该作者

『求助』 gcc的一些问题。。

楼主得给出代码,只这样问怎么能得到答案。

论坛徽章:
0
5 [报告]
发表于 2003-04-26 12:45 |只看该作者

『求助』 gcc的一些问题。。

有4.18M,是仿真的一个底层软件。。
在linux8.0下编译不出来。

论坛徽章:
0
6 [报告]
发表于 2003-04-26 21:52 |只看该作者

『求助』 gcc的一些问题。。

有没有哪位碰到类似的问题?
会不是会LINUX的版本问题???

论坛徽章:
0
7 [报告]
发表于 2003-04-26 22:00 |只看该作者

『求助』 gcc的一些问题。。

看它是编译什么源文件时报这个错的

另外这个问题好像前几天有人问过
但是我没有注意

可以试写一小段代码
使用new 操作看看能不能编译成功
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP