Inline ASM... Inline C ?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Inline ASM... Inline C ?

Post by Polo »

No, I'm joking, I know it's not possible to do some Inline C with Purebasic :)
No, what I'm asking in fact, is the possibility to do something like this :
you have a C source ("mytest.c") :

Code: Select all

extern void _stdcall mytestfunction(int value)
{
    return value;
}
And you have a PB source where you do that :

Code: Select all

IncludeC "mytest.c"
Declare mytestfunction(value.l)
Do you see what I mean ? I think you can do something like that with blitzmax, and this stuff is possible, you just have to include pocc (and again it's possible :))
this would be amazing, of course, we can build Purelibraries, but if you just want an easy function wrote in C, this would be awesome to have !!
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

In theory it could be done, has PB code is converted before being compiled...
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

As you said it's not hard to do (just pass the .c to pocc and link the obj), but i'm not really confident of the benefits, except than it will create a bastarized langage where some parts will be done in C and other in Basic (with all the interactions problems it will have). If we add the suggested 'Import' stuff, it should be easy as well to integrate C code (or anything else, because one could say IncludeCPP, IncludeDelphi/Pascal/Java etc..) to a PB project while keeping the langage clean.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

I agree with Fred, has this could bring more trouble than benefits.

Maybe an external tool could be created to import the C code into PB libraries...
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Yes, the import thing is not bad ;)
When do you expect to have it ready ? (I put the pressure on you :))
This Import feature would be really really cool !
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Num3 wrote:I agree with Fred, has this could bring more trouble than benefits.

Maybe an external tool could be created to import the C code into PB libraries...
Yes, a tool like that would have his place in the SDK folder :)
BTW, Fred, when do you plan to synchronise the SDK between Windows/Linux ? The Linux SDK is far better than the Windows one, there's a lot of includes and all :wink: !
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Ha yes, thanks for the remebering about the SDK, i will do it for the final v3.94.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Wow, cool, thanks again !!
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

While reading remember this: no offense ment.

Why should pb compile your c code, or add functionality to support a c compiler?
Which c compiler should Fred support?
pelles c?
lcc-win32?
gcc?
bcc?
ms?

As far as I can see Fred is already inclined to add obj support to pb.

So commands like:
IncludeCPP, IncludeDelphi/Pascal/Java are not necessary.
Maybe just one: IncludeOBJ.
(or make a compiler switch)

Just compile your code with the dedicated compiler and import the obj file.
(...with future versions of pb)
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

fsw: pellesc, I've wrote it in my post.
But then, why Purebasic should compile your ASM code as well ;)
It's just a matter of choice, and actually having the possibility of including .OBJ/.LIB is allright for me :)
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Polo wrote:fsw: pellesc, I've wrote it in my post.
But then, why Purebasic should compile your ASM code as well ;)
... maybe because pb compiles to asm.

Also pb compiles only for fasm.
So every piece of asm in pb code needs to follow fasm syntax.
If the coder uses gas syntax it wouldn't work, and I assume that Fred would not go ahead and support all assemblers out there.
Polo wrote: It's just a matter of choice, and actually having the possibility of including .OBJ/.LIB is allright for me :)
yeah for me too.

Take care
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

... maybe because pb compiles to asm.
Well, I know, but as Fred said, " it will create a bastarized langage where some parts will be done in C and other in Basic" (where you replace C by ASM :))
You see :)
But as I said it's no problem for me...
Post Reply