Bare metal programming in PureBasic, for experienced users
Wolfram
Enthusiast
Posts: 604 Joined: Thu May 30, 2013 4:39 pm
Post
by Wolfram » Sat Feb 15, 2025 7:33 pm
Hello,
why do get I this error on an ARM Mac?
"error: call to undeclared function 'read'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]"
On an Intel Mac the same code works.
macOS Catalina 10.15.7
Fred
Administrator
Posts: 18162 Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:
Post
by Fred » Sat Feb 15, 2025 8:26 pm
You need to declare it with clang (or include the .h)
Wolfram
Enthusiast
Posts: 604 Joined: Thu May 30, 2013 4:39 pm
Post
by Wolfram » Sun Feb 16, 2025 3:50 pm
If I include it like this I get an error "clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang: error: cannot specify -o when generating multiple output files"
Code: Select all
ImportC "unistd.h"
read_(fd, p_buf, size)
EndImport
macOS Catalina 10.15.7
Quin
Addict
Posts: 1125 Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:
Post
by Quin » Sun Feb 16, 2025 5:17 pm
I haven't tried this, but what if you do it with inline c?
like:
Fred
Administrator
Posts: 18162 Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:
Post
by Fred » Sun Feb 16, 2025 6:01 pm
You can try
Code: Select all
ImportC ""
read_(fd, p_buf, size)
EndImport
Wolfram
Enthusiast
Posts: 604 Joined: Thu May 30, 2013 4:39 pm
Post
by Wolfram » Mon Feb 17, 2025 5:43 pm
This example works
Code: Select all
ImportC ""
_read_(port, *read_buf, size)
EndImport
read_(port, *read_buf, size)
But how can use the C code to include th .h file?
This example does not work on my ARM Mac and why does the C function red() works without including on my Intel Mac ?
Code: Select all
! #include <unistd.h>
! read(v_serialport, p_buffer, 4);
macOS Catalina 10.15.7
ricardo_sdl
Enthusiast
Posts: 141 Joined: Sat Sep 21, 2019 4:24 pm
Post
by ricardo_sdl » Mon Feb 17, 2025 7:17 pm
Fred wrote: Sun Feb 16, 2025 6:01 pm
You can try
Code: Select all
ImportC ""
read_(fd, p_buf, size)
EndImport
What does the empty string after ImportC imply or mean?
Quin
Addict
Posts: 1125 Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:
Post
by Quin » Mon Feb 17, 2025 7:24 pm
ricardo_sdl wrote: Mon Feb 17, 2025 7:17 pm
Fred wrote: Sun Feb 16, 2025 6:01 pm
You can try
Code: Select all
ImportC ""
read_(fd, p_buf, size)
EndImport
What does the empty string after ImportC imply or mean?
It means you're importing a function from a library PB has already imported, just the function itself hasn't been imported.