Page 1 of 1
C Backend in PureBasic MacOS
Posted: Fri Jul 14, 2023 8:39 am
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.
Re: C Backend in PureBasic MacOS
Posted: Fri Jul 14, 2023 4:36 pm
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
Re: C Backend in PureBasic MacOS
Posted: Sat Jul 15, 2023 6:27 am
by Fred
Which version do you use on OSX ? What is not working ?
Re: C Backend in PureBasic MacOS
Posted: Sun Jul 16, 2023 8:32 am
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.
Re: C Backend in PureBasic MacOS
Posted: Sun Jul 16, 2023 8:45 am
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.
Re: C Backend in PureBasic MacOS
Posted: Sun Jul 16, 2023 10:26 am
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");
Re: C Backend in PureBasic MacOS
Posted: Wed Jul 19, 2023 10:36 am
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");
Re: C Backend in PureBasic MacOS
Posted: Fri Jul 21, 2023 4:10 pm
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()
Re: C Backend in PureBasic MacOS
Posted: Sat Jul 22, 2023 10:25 am
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.
Re: C Backend in PureBasic MacOS
Posted: Wed Aug 09, 2023 5:42 pm
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.