VC++ in PureBasic with Threads

Everything else that doesn't fall into one of the other PB categories.
Johan_Haegg
User
User
Posts: 60
Joined: Wed Apr 30, 2003 2:25 pm
Location: Västerås
Contact:

VC++ in PureBasic with Threads

Post by Johan_Haegg »

Got an idea when i saw Tiuri's post about HyperThreading and started to think about how threads could be implemented in a game that I and a few friends are planning.
First of all: is i possible to link stuff written i VC++ and PureBasic, and is i possible to thread a function written in VC++ within Purebasic
Second: Is it possible to have VC++ and PureBasic shareing varibels. (PureBasic reading from the same memory as the VC++ Function)

The second must be realy ugly, but as long as it does not crash.

I was thinking about:

VC++
Threaded Function:
repeat
Variabel = Whatever
forever

Threadreturn Function:
Return Variabel

PureBasic:
CreateThread(@Threaded_,0)
Variabel = Threadreturn_()
Seldon
Enthusiast
Enthusiast
Posts: 405
Joined: Fri Aug 22, 2003 7:12 am
Location: Italia

Post by Seldon »

I had such idea and wrote about it in another post (though i was thinking to use LCC and PB). Fasm (used by PB) produces standard objects files so it could be possible to link PB and C objects. Also Fred confirmed that. If C is the main object you should declare a PB function like this:

int _stdcall PBProcedure (VOID);

The only problem I think is how to link static PureBasic LIB files (in case the PB Procedure uses them) as they are not standard object files.
Johan_Haegg
User
User
Posts: 60
Joined: Wed Apr 30, 2003 2:25 pm
Location: Västerås
Contact:

Post by Johan_Haegg »

Well if I aint able to build it together, there is always DLL's
As soon as i find my Visual Studio 6.0-CDs i'll try it
spangly
User
User
Posts: 54
Joined: Mon Apr 28, 2003 8:26 pm
Contact:

Post by spangly »

I've been messing around with mixing C and PB. If you declare your C Functions in such a way:

Code: Select all

extern _stdcall DWORD PB_SomeFunction(DWORD fn,DWORD fl)
and output the code to a static library, you can use the tools in the Library SDK folder to create a PureLibrary. All the Functions marked with PB_ will apppear as Commands in PureBasic.
Post Reply