Mixing: Qbasic & C++

Programming, for all ages and all languages.
Post Reply
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Mixing: Qbasic & C++

Post 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
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Mixing: Qbasic & C++

Post 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.
Every good solution is obvious once you've found it.
CodeCat
Member
Member
Posts: 158
Joined: Tue Sep 23, 2008 1:45 pm
Location: Eindhoven, Netherlands

Re: Mixing: Qbasic & C++

Post 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.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Mixing: Qbasic & C++

Post 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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Re: Mixing: Qbasic & C++

Post 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:
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Mixing: Qbasic & C++

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply