nigg
asked on
Whats wrong with this code?
I'm not a C programmer (but Java) and need to get a c code working...
Code:
jbArray<java_object *>::primitiveArrayType java_object_array::array_t ype() const {
return jbArray::T_CLASS;
}
Gives me the following error at the compiler (on Linux):
../../../common/decaf/java _object.cc : In method `jbArray<java_object
*>::primitiveArrayType java_object_array::array_t ype () const':
../../../common/decaf/java _object.cc :219: use of class template `template <elem_
t> class jbArray' as
expression
../../../common/decaf/java _object.cc :219: parse error before `::'
../../../common/decaf/java _object.cc :220: warning: no return statement in functi
on returning non-void
../../../common/decaf/java _object.cc : In method
`jbArray<jfloat>::primitiv eArrayType java_jfloat_array::array_t ype ()
const':
Where do I look up the return type, like void? What do I need to change? For any help thanks...
BTW: Why does this not work?:
char ch = va_arg(args, char);
The compiler complains about wrong type...I put va_arg(args, int); and it compiled..But is this right?
Code:
jbArray<java_object *>::primitiveArrayType java_object_array::array_t
return jbArray::T_CLASS;
}
Gives me the following error at the compiler (on Linux):
../../../common/decaf/java
*>::primitiveArrayType java_object_array::array_t
../../../common/decaf/java
t> class jbArray' as
expression
../../../common/decaf/java
../../../common/decaf/java
on returning non-void
../../../common/decaf/java
`jbArray<jfloat>::primitiv
const':
Where do I look up the return type, like void? What do I need to change? For any help thanks...
BTW: Why does this not work?:
char ch = va_arg(args, char);
The compiler complains about wrong type...I put va_arg(args, int); and it compiled..But is this right?
Ummm.... that's C++ code you got there, not C code.
ASKER
Hi,
First off all, I did not get any mail notification...Just entered my question by mistake...
nebeker: You are right, how stupid from me...will consider this at the end...
peterdownes: OK, I understand more or less your example, so what's missing at my code above? I didn't catch it...sorry..
First off all, I did not get any mail notification...Just entered my question by mistake...
nebeker: You are right, how stupid from me...will consider this at the end...
peterdownes: OK, I understand more or less your example, so what's missing at my code above? I didn't catch it...sorry..
Can you post your code please.
Don't both nigg, I found the code on the internet.
Did you get it from here:
http://web.mit.edu/~tb/dev/jos/JJOS/common/decaf/java_object.h
http://web.mit.edu/~tb/dev/jos/JJOS/common/decaf/java_object.cc
Did you get it from here:
http://web.mit.edu/~tb/dev/jos/JJOS/common/decaf/java_object.h
http://web.mit.edu/~tb/dev/jos/JJOS/common/decaf/java_object.cc
ASKER
Yes, you are great...This should be the code I'm trying to compile...The project seams to be dead, but it looks like a nice start for a allmost native java system...
At http://web.mit.edu/~tb/dev/jos/JJOS/ is the whole distro...
At http://web.mit.edu/~tb/dev/jos/JJOS/ is the whole distro...
So, is this the code you are having problems with?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This worked great...thanks.But now I'm stuck at a other place:
../../../common/decaf/d_ma in.cc: In method `jjBoolean
(*decafJVM::lookupBuiltInM ethod (resolved_method *)) (java_word *,
frame *, resolved_method *, int)':
../../../common/decaf/d_ma in.cc:41: cannot convert `const utf8_native
*' to `utf8_native *' for argument `1' to `jbHashtable<KeyType,
DatumType>::lookup (KeyType) [with KeyType = utf8_native *, DatumType =
jjBoolean (*) (java_word *, frame *, resolved_method *, int)]'
make: *** [d_main.o] Error 1
Did they ever compile this stuff??
Maybe you try to compile it and tell me what to change? Increased the points. Thanks
../../../common/decaf/d_ma
(*decafJVM::lookupBuiltInM
frame *, resolved_method *, int)':
../../../common/decaf/d_ma
*' to `utf8_native *' for argument `1' to `jbHashtable<KeyType,
DatumType>::lookup (KeyType) [with KeyType = utf8_native *, DatumType =
jjBoolean (*) (java_word *, frame *, resolved_method *, int)]'
make: *** [d_main.o] Error 1
Did they ever compile this stuff??
Maybe you try to compile it and tell me what to change? Increased the points. Thanks
ASKER
mmmhh, http://web.mit.edu/~tb/dev/jos/JJOS/, does not match the sources I have, but both of them aren't compiling...Why didn't I learn C/C++??
But here the code I suspect making the error mentioned above:
This is from the header file:
builtInMethod lookupBuiltInMethod(resolv ed_method *rm, java_class* jc);
code from d_main.cc:
builtInMethod decafJVM::lookupBuiltInMet hod(resolv ed_method *rm)
{
constant_utf8 *foo = rm->namePtr();
const utf8_native *bar = foo->string();
/* $: why does lookup not use constant utf8_native pointers? */
builtInMethod baz = myBuiltinMethods->lookup(b ar);
.......
This is jjboolean:
jjBoolean decafJVM::main(int argc, char *argv[])
{
char * className;
/* fetch the class name for the zeroth thread */
if ( argc < 2 ) {
DEBUG(( "decafJVM::main(): using init as default" ));
className = "init";
} else {
className = argv[1];
} /* end class name fetch */
/*
* Create the zeroth thread.
*/
constant_utf8 *classname = new constant_utf8(className);
/* $: should be intern'd */
constant_utf8 *methodname = new constant_utf8("main");
java_thread *zeroth_thread = new java_thread(classname,
methodname,
myPrimordialClassLoader,
(java_word *)NULL,
0);
.............
I start to understand, why I didn't learn C/C++...:-)
But here the code I suspect making the error mentioned above:
This is from the header file:
builtInMethod lookupBuiltInMethod(resolv
code from d_main.cc:
builtInMethod decafJVM::lookupBuiltInMet
{
constant_utf8 *foo = rm->namePtr();
const utf8_native *bar = foo->string();
/* $: why does lookup not use constant utf8_native pointers? */
builtInMethod baz = myBuiltinMethods->lookup(b
.......
This is jjboolean:
jjBoolean decafJVM::main(int argc, char *argv[])
{
char * className;
/* fetch the class name for the zeroth thread */
if ( argc < 2 ) {
DEBUG(( "decafJVM::main(): using init as default" ));
className = "init";
} else {
className = argv[1];
} /* end class name fetch */
/*
* Create the zeroth thread.
*/
constant_utf8 *classname = new constant_utf8(className);
/* $: should be intern'd */
constant_utf8 *methodname = new constant_utf8("main");
java_thread *zeroth_thread = new java_thread(classname,
methodname,
myPrimordialClassLoader,
(java_word *)NULL,
0);
.............
I start to understand, why I didn't learn C/C++...:-)
ASKER
Here some more of the header file...I guess, that's important:
typedef jjBoolean (*builtInMethod)(java_word arg[], frame *frame, resolved_method *rm, int n_args);
typedef jbHashtable<utf8_native*, builtInMethod> builtinMethodHashTable;
class decafJVM
{
public:
decafJVM(jjMachine *jjmp, jbRamDisk *);
jjBoolean main(int argc, char *argv[]);
jjMachine *jjm(void) const;
scheduler *myscheduler(void);
builtInMethod lookupBuiltInMethod(resolv ed_method *rm);
protected:
void internBuiltInMethods(void) ;
void internBuiltInMethod(builtI nMethod fcnp, char *classname, char *fcnname);
scheduler myScheduler;
class_loader *myPrimordialClassLoader;
jjMachine *myjjMachine;
builtinMethodHashTable *myBuiltinMethods;
};
extern decafJVM *jvm;
typedef jjBoolean (*builtInMethod)(java_word
typedef jbHashtable<utf8_native*, builtInMethod> builtinMethodHashTable;
class decafJVM
{
public:
decafJVM(jjMachine *jjmp, jbRamDisk *);
jjBoolean main(int argc, char *argv[]);
jjMachine *jjm(void) const;
scheduler *myscheduler(void);
builtInMethod lookupBuiltInMethod(resolv
protected:
void internBuiltInMethods(void)
void internBuiltInMethod(builtI
scheduler myScheduler;
class_loader *myPrimordialClassLoader;
jjMachine *myjjMachine;
builtinMethodHashTable *myBuiltinMethods;
};
extern decafJVM *jvm;
Sorry nigg,
This could take me forever.
Hope someone else can assist.
Regards.
This could take me forever.
Hope someone else can assist.
Regards.
ASKER
Thanks....I'm going to post two new question, to get work....
template <class T> class Foo
{
void Bar(T* pT);
};
The method would be implemented as follows:
template<class T> void CEGMManager<T>::Bar(T* pT)
{
}