2025-03-17 2:42 AM
Hi, I trying to using VL53L5CX with my jetson nano.
Once I want to using it with arduino uno, but uno is not possibly for using with it.
So I trying to connected directly it on my jetson. I'm trying to following
VL53L5CX_Linux manual that downloaded from here.
https://www.st.com/en/embedded-software/stsw-img025.html
But for 3.2, I get some trouble. When I copied driver 2.0.0 folder on my jetson
and following the procedure(well, just simply use make as in manual)
it shows such error like this
./menu.c: In function ‘main’:
./menu.c:87:3: error: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Werror=unused-result]
87 | scanf("%s", choice);
| ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Well, I'm very new with using jetson nano. So I'm not sure what's the problem.
Maybe my jetson nano has some problems, that can't detect i2c connection with others
like this lidar sensor or arduino board,
this can be a problem?
I'm really appreciate if you give me any answer. Thank you.
2025-03-17 7:27 AM
If you are going to set your compile options to treat all warnings as errors, then you are going to have to be very robust indeed with the code.
Scanf is defined as:
int scanf(const char *format, ...);
and technically one should check the return value.
Oddly, in 40 years of programming C, I cannot recall having ever done it.
Wikipedia says,
"Return Values of scanf
The scanf function returns an integer value that indicates the number of input items successfully matched and assigned. Here are the possible return values:
Positive Value (>0): This indicates the number of input items successfully converted and assigned. For example, if scanf reads two integers successfully, it will return 2.
Zero (0): This indicates that no input items were assigned. This can happen if the input does not match the expected format.
Negative Value (<0): This indicates an error or end-of-file (EOF) condition before any input items were assigned. Typically, EOF is returned when the end of the input stream is reached.
Either change you're compile options to not treat warnings as errors, or just assign a return value to the scanf() call.
I suspect this will not be the only one of these you come across.
- john