C Backend in PureBasic MacOS

Just starting out? Need help? Post your questions and find answers here.
User avatar
Torf
User
User
Posts: 13
Joined: Thu Apr 27, 2023 8:03 pm

C Backend in PureBasic MacOS

Post by Torf »

Hello.

I don't know if this issue was commented in past... This is first time for me that I trie to compile PB and C code with pbcompilec and I'm surprised of it, it's a very very good tool can compile pb and c at the same time..Congratulations!!

What is the problem? Backend C only works in Windows, not in MacOS. I tested with several versions of PB and several versions of Windows (including WinXP 32 bits and Windows 10 64 bits) and several versions of PB (until the latest 6.03 Beta 3) but always the same result.

Is this a know issue? If it is, when is planned to fix?

Thanks in advance.
User avatar
mk-soft
Always Here
Always Here
Posts: 6209
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: C Backend in PureBasic MacOS

Post by mk-soft »

What should not work here.

The C-Backend compiler works for me under macOS

IDE settings compilers:

The only thing that is still stupid is that you have to extend the path to the compiler yourself.
[Path to Purebasic]/PureBasic.app/Contents/Resources/compilers/pbcompilerc

Ready to copy for add ;)

Code: Select all

/Contents/Resources/compilers/pbcompilerc
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: C Backend in PureBasic MacOS

Post by Fred »

Which version do you use on OSX ? What is not working ?
User avatar
Torf
User
User
Posts: 13
Joined: Thu Apr 27, 2023 8:03 pm

Re: C Backend in PureBasic MacOS

Post by Torf »

Fred wrote: Sat Jul 15, 2023 6:27 am Which version do you use on OSX ? What is not working ?
If I compile without #include <stdio.h> at top (but using PB in Windows this include is not needed and it compiles and runs OK) I get this error:

error: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Werror,-Wimplicit-function-declaration]
printf("Hola\n");
^
purebasic.c:65:2: note: include the header <stdio.h> or explicitly provide a declaration for 'print


And if I add the line #include at top and compile again, the error is:

error: function definition is not allowed here
__header_always_inline int __sputc(int _c, FILE *_p) {
^
1 error generated


I'm using a MacOS Monterey with MacBookAir chip Intel, and I tested with PB 6.01 LTS and 6.03 Beta 3.

Using MS Windows, I have not this problem and C Backend runs very well.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: C Backend in PureBasic MacOS

Post by Fred »

Do you mean you add a printf() as inlined assembly ? Please always post a small code source showing the problem or we can't help.
User avatar
mk-soft
Always Here
Always Here
Posts: 6209
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: C Backend in PureBasic MacOS

Post by mk-soft »

The macOS sdk standard header files do not seem to fit the gcc compiler.
My guess.

Code: Select all

!#include<stdio.h>
;!printf("Hola\n");
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Torf
User
User
Posts: 13
Joined: Thu Apr 27, 2023 8:03 pm

Re: C Backend in PureBasic MacOS

Post by Torf »

Fred wrote: Sun Jul 16, 2023 8:45 am Do you mean you add a printf() as inlined assembly ? Please always post a small code source showing the problem or we can't help.
The code is:

Code: Select all

! #include <stdio.h>
! printf("Hola, esto es C con PureBasic\n");
benubi
Enthusiast
Enthusiast
Posts: 215
Joined: Tue Mar 29, 2005 4:01 pm

Re: C Backend in PureBasic MacOS

Post by benubi »

I get an error with the include line, but none when removing it (W10 64bit PB6.02 C compiler). It displays the text in the console, but the console also has to be opened (long enough) to see it:

Code: Select all

OpenConsole()

! printf("Hola, esto es C con PureBasic\n");

Input() : CloseConsole()
User avatar
Torf
User
User
Posts: 13
Joined: Thu Apr 27, 2023 8:03 pm

Re: C Backend in PureBasic MacOS

Post by Torf »

benubi wrote: Fri Jul 21, 2023 4:10 pm I get an error with the include line, but none when removing it (W10 64bit PB6.02 C compiler). It displays the text in the console, but the console also has to be opened (long enough) to see it:

Code: Select all

OpenConsole()

! printf("Hola, esto es C con PureBasic\n");

Input() : CloseConsole()
Sure,as I wrote in my first message, it runs ok with Windows, and it fails with MacOS.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: C Backend in PureBasic MacOS

Post by Fred »

You can't use a function if not declared on OS X, it's stricter than the C compiler used on Windows. If you want to include stdio.h, you will have a to wait for the headerblock as you can't use #include inside a procedure.
Post Reply