Hartley Posted January 23, 2023 Share Posted January 23, 2023 Hello all, I have a build warning in my code: implicit declaration of 'read'; did you mean 'fread'? [-Wimplicit-function-declaration] The code works but the warning is annoying. I tried including <unistd.h> to pull in the declaration but that results in a build failure: conflicting types for 'sleep' conflicting types for 'usleep' Does anyone know what header can be included in Vitis to correctly get the prototype of 'read'? Thanks Link to comment Share on other sites More sharing options...
0 artvvb Posted January 30, 2023 Share Posted January 30, 2023 Hi @Hartley Assuming your project is a baseline Baremetal project, file I/O isn't necessarily implemented. You might need to bring in additional libraries that allow you to interact with a file system on, for example, an SD card. - I assume it's not baremetal if read works despite the warning. What's your project? Is this Vitis HLS or "plain-old" Vitis? Is this a petalinux project? Thanks, Arthur Link to comment Share on other sites More sharing options...
0 Hartley Posted February 8, 2023 Author Share Posted February 8, 2023 My project is a baseline Baremetal project. I'm using read() to get input from STDIN to allow user input of simple commands to test my hardware design. Basically: static void read_input(char* str) { printf("> "); fflush(stdout); int index = 0; char key; do { read(1, (char*)&key, 1); switch (key) { case 0x0D: // enter printf("\r\n"); break; case 0x7F: // backspace if (index > 0) { index--; str[index] = 0x00; printf("\r \r"); fflush(stdout); xil_printf("> %s", str); fflush(stdout); } break; default: str[index++] = key; printf("%c", key); fflush(stdout); } } while (key != 0x0D); str[index] = 0x00; } The function works fine I just wanted to get rid of the annoying warning during the build. read() is normally defined in <unistd.h> but including that breaks the build due to the conflicting types for 'sleep' and 'usleep'. But, read() must be available somehow since the code does run. I was just wondering where so I can include the proper header. Link to comment Share on other sites More sharing options...
Question
Hartley
Hello all,
I have a build warning in my code:
implicit declaration of 'read'; did you mean 'fread'? [-Wimplicit-function-declaration]
The code works but the warning is annoying.
I tried including <unistd.h> to pull in the declaration but that results in a build failure:
conflicting types for 'sleep' conflicting types for 'usleep'
Does anyone know what header can be included in Vitis to correctly get the prototype of 'read'?
Thanks
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now