Running directly C code with v6.00 [Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Running directly C code with v6.00

Post by Kwai chang caine »

mk-soft wrote: Sat May 29, 2021 8:01 pm Yes, you can insert C code into PB with "!" and it works.
It's a good news !!! :D
mk-soft wrote: Sat May 29, 2021 8:01 pm If you need header files that are not defined. You have to insert them yourself.
You want to say "yourself" master :mrgreen:
Because KCC.... can't even do a "Hello word" in C :oops:
But, if you have a simple example, for the future...... i am not against :wink:
juergenkulow wrote:Show the Error?!
Do you also have the following error messages on your machine?
One thousand of thanks for trying the feat to make KCC a little bit smarter 8)
Other masters of this site have tried many times 8) without success, but I think your great example is a little bit too complicated for the little KCC. :oops:

FIRACE and USEFUL have give to me exactely what i search :wink:
You know....two lines is already an adventure for KCC in C :mrgreen:
But again thanks for your patience and your great example 8)
FIRACE wrote:@KCC
Why don't you simply try it this way (includes are not needed):
Because i'm a donkey :oops:
Since all this time in the familly, I would have thought that our dad FRED had already thought of chewing our job like with the native PB 8)
FIRACE wrote:(includes are not needed):
Very good news too !! Justly, ...do you think we could have the list of libraries already included by FRED ? for not do the same error :oops:
In all case, thanks a lot for your simple (like KCC :mrgreen: ) code 8)
Useful wrote:! printf("Hello world!\n");
! getchar();
Waooouh again shorter !!! :shock:
Soon, there won't even be a need to put a single character anymore, just to compile :lol:
Thanks too, for your great simple example like KCC love 8)
Marc56 wrote:And it works.
and more simply, see the answers of fireace and useful
Yes !!!! now i use that :wink:
I'm not ready to forget this two first C lines in my life 8)

@ALL
Thanks a lot at all for your precious help
Little KCC is so proud to be in the great familly of MASTERS like you all 8)
Even if... he's always running far behind you all !!!! :mrgreen:

Have all, a the very best good day of the universe !!!!

@FRED & TEAM
And obviously, again thanks to our FRED and the team, for create this miracle of christmas in the middle of the year :shock:
Another proof, that with PB....all is possible 8)

Even in my biggest dream... I couldn't have thought it was possible
My two love of language on three (ASM definitively too hard for me :oops: ), C and PB in the same code... :shock:
I'm happy to still be alive for having seen that 8)
Thanks to PB, the great C can be USB PORTABLE it's one of the reason i have choose PB in the beginning 8)
ImageThe happiness is a road...
Not a destination
Cezary
User
User
Posts: 89
Joined: Sun Feb 12, 2017 2:31 pm

Re: Running directly C code with v6.00 [Resolved]

Post by Cezary »

Maybe someone knows if something similar to EnableASM / DisableASM is planned instead of an exclamation mark at the beginning of the line?
Is there any way to rigidly declare variables (int32_t, uint8_t etc.)?
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Running directly C code with v6.00 [Resolved]

Post by Kwai chang caine »

ImageThe happiness is a road...
Not a destination
juergenkulow
Enthusiast
Enthusiast
Posts: 544
Joined: Wed Sep 25, 2019 10:18 am

Re: Running directly C code with v6.00 [Resolved]

Post by juergenkulow »

Hello Cezary,

Code: Select all

! typedef int  int32_t;
! typedef unsigned char   uint8_t;
! int32_t v_i=47114712;
! uint8_t v_c='x';
MessageRequester("","i="+Str(i.l)+" c="+Chr(c.a))

CompilerIf Defined(PB_Processor_C,#PB_Constant) 
  CompilerIf #PB_Compiler_Processor<>#PB_Processor_C
    CompilerError "Use C Backend Compiler in Compiler-Option"
  CompilerEndIf   
CompilerElseIf Defined(PB_Compiler_Backend,#PB_Constant) 
  CompilerIf #PB_Compiler_Backend<>#PB_Backend_C
    CompilerError "Use C Backend Compiler #PB_Compiler_Home Compilers\pbcompilerc"
  CompilerEndIf 
CompilerElse
    CompilerError "Please install PureBasic version >=6.00 Alpha."
CompilerEndIf 

Code: Select all

// stdint.h
//...
typedef int  int32_t;
typedef unsigned char   uint8_t;
typedef signed char int8_t;
typedef short  int16_t;
typedef unsigned short  uint16_t;
typedef unsigned   uint32_t;
typedef long long  int64_t;
typedef unsigned long long   uint64_t;
//...
edit: CompilerIf #PB_Compiler_Backend<>#PB_Backend_C
Last edited by juergenkulow on Sat Jun 19, 2021 5:12 pm, edited 1 time in total.
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: Running directly C code with v6.00 [Resolved]

Post by Olli »

Don KC++ wrote:do you think we could have the list of libraries already included by FRED ?
I think that yes : in ASM, there was already an access to its internal functions, by adapting the calling syntax on ASM. I do not see why there would not be a similar access, just by adapting the calling syntax on C, instead of ASM.

It is a very big idea, accessing to the C execution. But if you test each I/O data object (array, list and map) interchange between PureBasic and C, you do not need really to roll your brain, by adapting everything : the main mastering for you is to know reading and writing the PureBasic arrays, lists and maps (and all the types of PureBasic Datas) in C.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Running directly C code with v6.00 [Resolved]

Post by Kwai chang caine »

@Ollivier with two wings
In all case....purebasiC is again more wonderfull with this new back-end, finally.... if it's already possible :wink:
The ASM was also a great thing, but in my opinion even less accessible as a language, already that C is not always.
ImageThe happiness is a road...
Not a destination
Post Reply