c backend, ability to define C functions.

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

c backend, ability to define C functions.

Post by jassing »

Would be nice to be able to define a C function w/in PB code...

Code: Select all

BeginCSection
! int testC( int i ) {
!   return(++i);
! }
EndCSection
Procedure test()
  Define v 
  !v_v = testC( 3 ); 
EndProcedure
test()
Hmm. maybe not "csection" considering it might be taken the wrong way for the procedure by similar name. (BeginGlobalC?)
and yes, I know I can define it inside a procedure...
User avatar
idle
Always Here
Always Here
Posts: 5050
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: c backend, ability to define C functions.

Post by idle »

Not unless you want to get yelled at by Karen.

All that's needed is to have
#include and #define moved out of the main scope.
That would then facilitate you writing a c function and calling it.

+1
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

Re: c backend, ability to define C functions.

Post by jassing »

idle wrote: Mon Jun 12, 2023 12:46 am Not unless you want to get yelled at by Karen.
Fun with Dyslexia...

I read that as "yelled at by the Kraken" - and I thought, yes, as a sailor, I am very much afraid of the kraken.
User avatar
Kuron
Addict
Addict
Posts: 1626
Joined: Sat Oct 17, 2009 10:51 pm
Location: Pacific Northwest

Re: c backend, ability to define C functions.

Post by Kuron »

+1 for being afraid of the 🦑
Best wishes to the PB community. Thank you for the memories. ♥️
Fred
Administrator
Administrator
Posts: 16623
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: c backend, ability to define C functions.

Post by Fred »

May be an HeaderSection/EndHeaderSection would be OK, so it could work for all backends.
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

Re: c backend, ability to define C functions.

Post by jassing »

Fred wrote: Mon Jun 12, 2023 10:11 am May be an HeaderSection/EndHeaderSection would be OK, so it could work for all backends.
that'd work & be a nice addition. Thank you for considering it.
User avatar
idle
Always Here
Always Here
Posts: 5050
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: c backend, ability to define C functions.

Post by idle »

Fred wrote: Mon Jun 12, 2023 10:11 am May be an HeaderSection/EndHeaderSection would be OK, so it could work for all backends.
yes if you do that it will solve a lot of the problem with c backend.
Post Reply