|
I guess that is down to the fact that there have been major changes since VS2003 and VS2005. But, as I mentioned above, you should use the latest toolset that is available.
|
|
|
|
|
it compiled for one of the projects after some tinkering
i had to change the debug source files and point them to VC2003
added _CRT_SECURE_NO_DEPRECATE & _XKEYCHECK_H in preprocessors definitions
and fixed some codes
it runs even better than before, i have no clue how or why
ill try & do the same to the other projects and maybe i will get lucky
|
|
|
|
|
Why do you insist on using out of date toolsets? Whatever short term improvements you might see there is a potential for major problems suddenly appearing.
|
|
|
|
|
im not insisting on anything, im just a hobbyist, what choice do i have?
im just trying to make working with these projects easier.
if you like i can send you the codes and you can fix them for me, but i dont think you or anyone here would do that, so here i am only asking questions.
|
|
|
|
|
hmd-omani wrote: what choice do i have? As I keep telling you, the simple choice: use the toolset that goes with the version of Visual Studio that you are using.
|
|
|
|
|
so far so good but with my last project i got this warning c4474 saying too many arguments
sscanf(parm, "%%.2f", &f );
i added the extra % and it removed one warning already
any clues?
|
|
|
|
|
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 );
[edit]
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.
[/edit]
modified 21-Jul-20 16:22pm.
|
|
|
|
|
why change the 2 to 5?
i removed the dot between % and 2 and it worked, i dont know if thats fine or not if i kept at 2?
|
|
|
|
|
Because that is the maximum number of characters it will scan. So %2f will not work for 1.75, or 11.6 for example.
[edit]
Try this code, it will show you what I mean:
char zzz[32];
char* pp = "23.58";
float ff;
sscanf(pp, "%2f%s", &ff, zzz);
printf("Number is: %.2f\n", ff);
printf("String is: %s\n", zzz);
[/edit]
modified 22-Jul-20 7:53am.
|
|
|
|
|
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.
Mircea
|
|
|
|
|
i didn't change the platform toolsets, only the debug source files
|
|
|
|
|
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.
Mircea
|
|
|
|
|
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.
Cheers
This is really driving me nuts.
The verbose output form complier and project GUI will show same
/usr/include....
However
only full path include file passes test
#include /usr/include/gtkmm-3.0/gtkmm.h
Including gtkmm.h by itself , will show
"unresolved inclusion"
#include "gtkmm.h"
On top of this - build is successful, no errors and it runs.
So "unresolved inclusion" error is no error ?
modified 22-Jul-20 13:06pm.
|
|
|
|
|
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.
Keep Calm and Carry On
|
|
|
|
|
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.
Addendum
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?
( See the other discussion about backtick.)
modified 18-Jul-20 20:59pm.
|
|
|
|
|
It's official - adding `pkg-config gtkmm-3.0 --cflags --libs` to either complier or linker options generates this problem.
If there is #include file in source WHICH cannot be found, it is flagged , but the build is without an error and runs.
As far as build goes there are NO errors!
Is it possible I am putting the backtick string in wrong place ?
|
|
|
|
|
In Eclipse, you open the Properties of your project -> expand "C/C++ General" -> "Paths and Symbols".
include dir is not right add the directory to it or fix what is there
It throws that warning then goes down the search path set in enviroment and then finds it.
So you end up compiling fine with a stupid warning in between.
In vino veritas
|
|
|
|
|
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.
Cheers
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.
Cheers
CODE DELETED
Addendum
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.
Cheers
modified 22-Jul-20 13:07pm.
|
|
|
|
|
Run your backticked phrase (without backticks), redirected to a file. Then you can see what it injects into your command line when it's used backticked.
Something like
pkg-config --cflags gtk+-3.0 > lookatmeclosely
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
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 ?
Addendum
Did some research and found this
z@z-desktop $ pkg-config --libs gtk+-3.0
-lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
That is what is needed.
However adding another backtick string `pkg-config --libs gtk+-3.0` did not produced expected libraries.
Will do some experimentation with that - it should work.
More edit
If I add
`pkg-config --libs gtk+-3.0` to linker options I get about 20 additional -l libraries in output.
However I still get "undefined reference " error.
Later...
modified 16-Jul-20 22:43pm.
|
|
|
|
|
Make sure you are adding the --libs option to the link phase in your IDE. e.g.
compiler flags : ... `pkg-config --cflags gtk+-3.0` ...
linker flags : ... `pkg-config --libs gtk+-3.0` ...
As an aside, you should be aware that the backtick idiom is a shell level construct, and is not anything specific to gcc. so you could do the following :
$ ls -l `find . -name *.cpp`
Which would produce a long listing of all cpp files in the current directory tree.
Keep Calm and Carry On
|
|
|
|
|
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
gtk:
z@z-desktop $
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 ?
Appreciate all the help with such trivial issue.
Cheers
|
|
|
|
|
OK, this makes no sense
Eclipse IDE has under includes
/usr/include
BUT
I had to add this full path manually to get rid of " file doe snot exist " AKA undefined reference
#include /usr/include/gtk-3.0/gtk/gtk.h
( < > won't show !!!! )
Now my first usage of GTK gives the "undefined reference " error - same as the very old post on Eclipse.
In my view - the "top reference" is OK, but anything "bellow" is still unreferenced.
This is a mess...
|
|
|
|
|
I'm fairly sure that the "undefined reference" is a link phase error, not a compile phase problem, so I don't think changing the headers or header search path will not help you
Vaclav_ wrote: Eclipse IDE has under includes
/usr/include
I don't use eclipse, but it looks to me like that's a path, so I think you would add
/usr/include/gtk-3.0
assuming you're adding #include <gtk gtk.h=""> to your source file
If you're getting the object files compiled successfully, but not getting the linking done then try, from a command line
gcc file1.o file2.o ... `pkg-config --libs gtk+-3.0` -o myapp
if you're compiling C++ code, use g++ to link, not gcc, as that will link in stdlib++.o, and do anything else that C++ needs that plain C doesn't
I don't see where you've said exactly what the undefined reference you're getting is. Its possible that its not a gtk+ function, but maybe a math (eg. abs, ceil cos) or function from another library.
Keep Calm and Carry On
|
|
|
|