Getting memory address out of c into bmax

BlitzMax Forums/BlitzMax Programming/Getting memory address out of c into bmax

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

@Dreamora
It is infact returning the correct address of the 'texture variable' as a integer value. Thanks, coz you made me remember there are variable pointers built into blitz :)

@mouss38
Are you trying to access structures from a c program but within bmax? If so, then I just solved that problem ( well, one way - from c into bmax at the mo ) :p


c program:
typedef struct 
{
	int x;
	int y;
} test;


test t;

//test function
long GetPointer()
{	
	t.x=10;
	t.y=20;

	return &t;
}


.mod program:
Extern
	Function GetPointer:Int Ptr()
EndExtern

Function GetMemPtr:Int Ptr()
	Return GetPointer()
End Function


.bmax program:
Local test:Int Ptr
test = getmemptr()

Print test[0]

test:+1

Print test[0]

'or you could use:-
test = getmemptr()
Print test[0]
Print test[1]


Does this help?
[EDITED} Strange..... for some reason a c++ version of the program gives an 'undefined reference to `GetPointer' ' error.
[EDITED ADGAIN] OK, So I've learned that the calling conventoin in c++ needs the 'extern 'c' ' command around your function prototypes. Learning more and more everyday.....