在ns2.28下編譯ns-aedcf出現以下錯誤
錯誤提示:
misc.cc:65:erro:'strtoq' undeclared (first use this function)
misc.cc:65:erro:(Each undeclared identifier is reported only once for each function it appears in.)
misc.cc檔案代碼如下
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/misc.cc,v 1.10 1999/09/28 03:46:31 heideman Exp $ (LBL)";
#endif
#include <stdlib.h>
#include <math.h>
#ifndef WIN32
#include <sys/time.h>
#endif
#include <ctype.h>
#include "config.h"
#include "scheduler.h"
#include "random.h"
#define strtoll _strtoi64
#if defined(HAVE_INT64)
class Add64Command : public TclCommand {
public:
Add64Command() : TclCommand("ns-add64") {}
virtual int command(int argc, const char*const* argv);
};
int Add64Command::command(int argc, const char*const* argv)
{
Tcl& tcl = Tcl::instance();
if (argc == 3) {
char res[22]; /* A 64 bit int at most 20 digits */
int64_t d1 = STRTOI64(argv[1], NULL, 0);
int64_t d2 = STRTOI64(argv[2], NULL, 0);
sprintf(res, STRTOI64_FMTSTR, d1+d2);
tcl.resultf("%s", res);
return (TCL_OK);
}
tcl.add_error("ns-add64 requires two arguments.");
return (TCL_ERROR);
}
#endif
class RandomCommand : public TclCommand {
public:
RandomCommand() : TclCommand("ns-random") { }
virtual int command(int argc, const char*const* argv);
};
/*
* ns-random
* ns-random $seed
*/
int RandomCommand::command(int argc, const char*const* argv)
{
Tcl& tcl = Tcl::instance();
if (argc == 1) {
sprintf(tcl.buffer(), "%u", Random::random());
tcl.result(tcl.buffer());
} else if (argc == 2) {
int seed = atoi(argv[1]);
if (seed == 0)
seed = Random::seed_heuristically();
else
Random::seed(seed);
tcl.resultf("%d", seed);
}
return (TCL_OK);
}
extern "C" char version_string[];
class VersionCommand : public TclCommand {
public:
VersionCommand() : TclCommand("ns-version") { }
virtual int command(int, const char*const*) {
Tcl::instance().result(version_string);
return (TCL_OK);
}
};
class TimeAtofCommand : public TclCommand {
public:
TimeAtofCommand() : TclCommand("time_atof") { }
virtual int command(int argc, const char*const* argv) {
if (argc != 2)
return (TCL_ERROR);
char* s = (char*) argv[1];
char wrk[32];
char* cp = wrk;
while (isdigit(*s) || *s == 'e' ||
*s == '+' || *s == '-' || *s == '.')
*cp++ = *s++;
*cp = 0;
double v = atof(wrk);
switch (*s) {
case 'm':
v *= 1e-3;
break;
case 'u':
v *= 1e-6;
break;
case 'n':
v *= 1e-9;
break;
case 'p':
v *= 1e-12;
break;
}
Tcl::instance().resultf("%g", v);
return (TCL_OK);
}
};
void init_misc(void)
{
(void)new VersionCommand;
(void)new RandomCommand;
(void)new TimeAtofCommand;
#if defined(HAVE_INT64)
(void)new Add64Command;
#endif
}
uj5u.com熱心網友回復:
錯誤出現在這一行int64_t d1=STRTOI64(argv[1],NULL,0);
uj5u.com熱心網友回復:
盡量用版本高的編譯器去編譯。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/143375.html
標籤:網絡及通訊開發
上一篇:!!!十萬火急求救:使用MemTableEh后DbGridEh中無法直接編輯資料
下一篇:繼續XE2中png不規則視窗問題
