Page 1 of 1
c backend, ability to define C functions.
Posted: Fri Jun 09, 2023 11:36 pm
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...
Re: c backend, ability to define C functions.
Posted: Mon Jun 12, 2023 12:46 am
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
Re: c backend, ability to define C functions.
Posted: Mon Jun 12, 2023 1:47 am
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.
Re: c backend, ability to define C functions.
Posted: Mon Jun 12, 2023 2:41 am
by Kuron
+1 for being afraid of the

Re: c backend, ability to define C functions.
Posted: Mon Jun 12, 2023 10:11 am
by Fred
May be an HeaderSection/EndHeaderSection would be OK, so it could work for all backends.
Re: c backend, ability to define C functions.
Posted: Mon Jun 12, 2023 12:50 pm
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.
Re: c backend, ability to define C functions.
Posted: Tue Jun 13, 2023 5:19 am
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.