Page 1 of 1
Error read() on macOS arm64
Posted: Sat Feb 15, 2025 7:33 pm
by Wolfram
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.
Re: Error read() on macOS arm64
Posted: Sat Feb 15, 2025 8:26 pm
by Fred
You need to declare it with clang (or include the .h)
Re: Error read() on macOS arm64
Posted: Sun Feb 16, 2025 3:50 pm
by Wolfram
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
Re: Error read() on macOS arm64
Posted: Sun Feb 16, 2025 5:17 pm
by Quin
I haven't tried this, but what if you do it with inline c?
like:
Re: Error read() on macOS arm64
Posted: Sun Feb 16, 2025 6:01 pm
by Fred
You can try
Code: Select all
ImportC ""
read_(fd, p_buf, size)
EndImport
Re: Error read() on macOS arm64
Posted: Mon Feb 17, 2025 5:43 pm
by Wolfram
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);
Re: Error read() on macOS arm64
Posted: Mon Feb 17, 2025 7:17 pm
by ricardo_sdl
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?
Re: Error read() on macOS arm64
Posted: Mon Feb 17, 2025 7:24 pm
by Quin
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.