本人在用VC6.0做SpiderMonkey时候遇到这样一个错误
本人在用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;
}