Page 1 of 1

Mixing: Qbasic & C++

Posted: Mon Oct 20, 2008 1:29 am
by i586coder
Hello folks,

I had many experiences around mixing languages
e.g.
qbasic <-> assembly
qbasic <-> pascal
c++ -> qbasic
c++ <-> assembly

but i failed to make mix between qbasic & C++ ( C++ <- qbasic )
i think there is one method to do that,
declare qbasic function as pascal in c++

in qbasic

Code: Select all

 function addone%(n as integer)
             addone%= n + 1
 end function
& i compiled qbasic code & generate qbtst.OBJ

in C++

Code: Select all

 extern "C"{
  int pascal addone(int);
 }

main(){
 int  foo;
  foo=addone(3);//foo must be 4
}
finally, link all .OBJ files
and compiler say:

Linker Error: Undefined symbol addone in module F:\mix.CPP


need your comments :!: :!:

ThankX :roll:

Cheers,
Ahmad T. Dajani

Re: Mixing: Qbasic & C++

Posted: Mon Oct 20, 2008 3:56 am
by Solar
I don't know anything about QBasic, but I'd use objdump to list the symbols from both object files. It might be as simple as a missing underscore.

Re: Mixing: Qbasic & C++

Posted: Mon Oct 20, 2008 4:49 am
by CodeCat
Indeed, name mangling is probably your problem. If you're using GCC you could use the -fno-leading-underscore option to GCC to make the names compatible.

Re: Mixing: Qbasic & C++

Posted: Mon Oct 20, 2008 8:27 am
by Love4Boobies
It's nice to experiment but I'm not sure I see the reason behind all of this. If you want something more low-level than C++, there's C (also Pascal), which you already managed. Both C and Pascal support stuff like GOTOs, etc.

Re: Mixing: Qbasic & C++

Posted: Mon Oct 20, 2008 8:46 am
by i586coder
WELL,

I got a library for qbasic "3d4qb.lib" i think #-o
This lib include many functions around 3d (scale,rotate,...) :shock:
it's hard to start like this project form scratch since i want only some
functions from that lib in my C code :?
so, i decide to disassemble it,& i do it ,but huge library like this in assembly langauge is terrible to understand,isn't it :wink:

thanX again :mrgreen:

Re: Mixing: Qbasic & C++

Posted: Mon Oct 20, 2008 9:16 am
by Combuster
You may consider to write your code against Direct3D's math library instead. And there probably are many more libraries that do math stuff for you.

I see no real need for quickbasic other than it being totally outdated.