本人在用VC6.0做SpiderMonkey时候遇到这样一个错误

zouyu01 2008-04-20 12:11:20
本人在用VC6.0做SpiderMonkey时候遇到这样一个错误
--------------------Configuration: js8 - Win32 Debug--------------------
Compiling...
StdAfx.cpp
Compiling...
js8.cpp
d:\microsoft visual studio\vc98\include\jstypes.h(234) : fatal error C1189: #error : "Must define one of XP_BEOS, XP_OS2, XP_WIN or XP_UNIX"
执行 cl.exe 时出错.

js8.exe - 1 error(s), 0 warning(s)


// js8.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
/* include the JS engine API header */
#include "jsapi.h"
int main(int argc, char* argv[])
{/*set up global JS variables, including global and custom objects */

JSRuntime *rt;
JSContext *cx;

/* initialize the JS run time, and return result in rt */
rt = JS_NewRuntime(8L * 1024L * 1024L);

/* if rt does not have a value, end the program here */
if (!rt)
return 1;

/* create a context and associate it with the JS run time */
cx = JS_NewContext(rt, 8192);
/* if cx does not have a value, end the program here */
if (cx == NULL)
return 1;

/* 初始化内置JS对象和全局对象 */

JSObject *global;
JSClass global_class = {
"global",0,
JS_PropertyStub,JS_PropertyStub,JS_PropertyStub,JS_PropertyStub,
JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
};

global = JS_NewObject(cx, &global_class, NULL, NULL);
JS_InitStandardClasses(cx, global);

std::string script = "var today = Date(); today.toString();";
jsval rval;
uintN lineno = 0;
JSBool ok = JS_EvaluateScript(cx, global, script.c_str(),
script.length(), "script", lineno, &rval);

JSString *str = JS_ValueToString(cx, rval);
std::cout << JS_GetStringBytes(str);

JS_DestroyContext(cx);
JS_DestroyRuntime(rt);

return 0;
}
...全文
76 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zouyu01 2008-04-20
  • 打赏
  • 举报
回复
问题 已经解决 只要在头文件#include <jsapi.h>前 定义#define XP_WIN 就可以了

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧