Too many % characters there. Remember in a printf/scanf format the % is the control character, so two of them means print (or read) a single "%" character. So in your call it expects to read a string of the form "%.2f", and requires no parameters. It should be:
sscanf(parm, "%5f", &f ); // single % character to introduce the format, read up to 5 character float value.
The width value for scanf indicates the maximum number of characters to read for that field, so does not require the dot prefix, but should be large enough for the largest number.
See updated code.
That’s a good example of why you should upgrade to a new toolset: sscanf is a variadic function with a variable number of arguments. Older toolsets didn’t bother to do any analysis on the arguments while the newer ones interpret the format string the same way it would be interpreted at runtime and check if the arguments match. In your case they don’t because the ‘%’ sign looses it’s special function if it is escaped by another ‘%’ sign. VC19 is just trying to warn you about a probable bug in your code.
Not sure what you mean by changing only the debug source. There are however two problems with your format specifier:
- sscanf formats do not have a point for number of decimal places (unlike printf formats).
- percent sign must be escaped to read a percent sign from the input.
So, if you want to read something like "%12.34", the correct sscanf format is "%%%5f".
VS2019 warns you if you are missing the triple percent because the last argument of sscanf will not used.
I can only assume that eclipse is doing something. Normally, a header file that can't be found results in a fatal error. If you really are using #include "gtkmm.h", maybe eclipse is searching the project directory for the include file and that is what is generating the warning message. GCC/G++ on the other hand, searches the project directory and then the normal system directories for "" delimited include files Include Syntax (The C Preprocessor) If it is the case that you're using #include "gtkmm.h" try changing to #include <gtkmm.h>, and see if that removes the warning.
If it is the case that you're using #include "gtkmm.h" try changing to #include <gtkmm.h>, and see if that removes the warning.
I do not know how to enter greater / less then charactere here.
I did try #include <gtkmm.h> ( i just cut and paste your text ) with same result.
If you czech my next post you will find the answer - I am inclined to believe it is IDE problem.
After I did "new project" from scratch the build fails as expected when the file cannot be found.
This is just to keep the discussion going.
I did not verify this , but it looks as every time backtick string is added the build process has no error but the includes which cannot be satisfied are flagged as such in source file.
I am begging to question WHERE does the backtick string belong - as an option to complier or elsewhere?
I have used eclipse extensively in the past and it works fine. Your comment re double quotes versus angle brackets is correct. But that (and all the other issues) are nothing to do with eclipse, but about how the compiler search paths work.
SOLVED case closed
As expected - pkg-config DOES NOT integrate with just any Eclipse version / release.
I got it working as expected in 2018-09!
Sorry for wasting everybody time.
It is my understanding that the characters enclosed in backticks execute and the result is passed as option(s) to the GCC.
`pkg-config --cflags gtk+-3.0`
I have added the backticks string to both GCC compiler and linkers options and still getting the usual "undefined reference" error.
The tutorial does not explain much about implementing this backticks string.
(Should it add library -l refernces ??)
I woudl appreciate references or comments on this and suggestions how to actually resolve this issue.
I am enclosing the complier / liker verbose output for information, and I am sorry to take so much bandwidth with it.
I do not like blaming problems elsewhere, BUT,
this problem is really not related to using backtick syntax. After some trials it works as expected.
There were few other problems AFTER I updated to latest version of IDE. So I down paddled to previous, working release and imported the GTK project there.
Just build a clean GTK project and it works as expected.
I am sorry for wasting everybody time with a problem related to flaky IDE.
Thanks, but I know what is does - look at all the -I in the attached file. I think g++ also needs -l - libraries or library - for GTK.
But I am not sure how to do it if I need more.
Can I use similar method
as pkg-config to get -l /-L ?
OK, putting wrong option may be one of the issues.
I did put BOTH --cflag and --libs in complier and linker options. I also tried
this combined syntax
`pkg-config --cflags --libs gtk+-3.0`
The compiler and linker verbose outputs looks OK ( too big to repost here ) , BUT the unresolved error is apparently different issue.
I am enclosing what I posted in Eclipse forum here:
This error has been posted years ago and there was NO SOLUTION,
See this old post
[b]However, this only solved the issue of adding all the header files manually. Now I encounter errors like "Function 'G_CALLBACK' could not be resolved". I tried to compile my source-code (the first example of the GTK3 tutorial) in a terminal using the simple "gcc `pkg-config --cflags gtk+-3.0` -o example-0 First_GTK_test.cpp `pkg-config --libs gtk+-3.0`" command and it works. So the issue must be an Eclipse setting issue.[/b]
Every GTK tutorial is same - download / install GTK and run sample code in your editor...
It is up to the user to figure out how to option complier / linker to "include sources and link libraries"
Adding `pkg-config --cflags --libs gtk+-3.0` should work, I get expected verbose output , but it does not.
Even after that is done the compilation will fail because #include <gtk gtk.h=""> is unresolved.
Here is an output of whereis
z@z-desktop $ whereis gtk.h
Any help woudl be appreciated
End of Eclipse post.
I am really at lost where the reference
<gtk gtk.h=""> came from and unsure how to find gtk.h manually - where ?