Page 1 of 1

Inline ASM... Inline C ?

Posted: Mon Jun 13, 2005 10:33 am
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 !!

Posted: Mon Jun 13, 2005 12:20 pm
by Num3
In theory it could be done, has PB code is converted before being compiled...

Posted: Mon Jun 13, 2005 12:41 pm
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.

Posted: Mon Jun 13, 2005 12:44 pm
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...

Posted: Mon Jun 13, 2005 12:45 pm
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 !

Posted: Mon Jun 13, 2005 12:46 pm
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: !

Posted: Mon Jun 13, 2005 12:52 pm
by Fred
Ha yes, thanks for the remebering about the SDK, i will do it for the final v3.94.

Posted: Mon Jun 13, 2005 12:56 pm
by Polo
Wow, cool, thanks again !!

Posted: Mon Jun 13, 2005 6:27 pm
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)

Posted: Mon Jun 13, 2005 6:41 pm
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 :)

Posted: Mon Jun 13, 2005 8:17 pm
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

Posted: Mon Jun 13, 2005 8:38 pm
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...