g++ does not ignore "deprecated-declaration" + "Werror" error when using "-Wno-deprecated" - c++

The same case from the strikethrough case down here. I have a deprecated function call, and it gives an error. I want to ignore it for now. I can use #undef but I prefer using a "-Wno-deprecated" compilation flag, but for some reason I stil get the same error.
I have two modules with calls to the depracted functoin:
SSH_DEPRECATED LIBSSH_API int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash);
// SSH_DEPRECATED == __attribute__ ((deprecated))
// as can be seen from:
// #define SSH_DEPRECATED __attribute__ ((deprecated))
Module A (the errornous module) ouputs a "is depracted" warning made error. I assumed the reason I saw only one error was because the compilation flags of A included -Werror. However, both of the modules include the same flag.
However, module B has something different. A includes libssh.h from arm-buidroot-linux-gnueabi where B includes that libssh.h and another copy of libssh.h (I assume the 2nd copy is a copy-paste of an older version of libssh.h).
I assumed that the SSH_DEPRECATED does not appear on the 2nd libssh.h, but I was wrong, so now I'm not what could be the reason.
Currently I got it to work by removing the -Werror in A, but this is bad since:
I don't know what is the root cause (i.e. how come it works in B)
I do want that flag [-Werror] (this can be solved by adding -Wno-deprecated
and then returning the -Werror, but I don't think of it as a good solution. More like a hack)
My question: What in A can cause this deprecated warning that does not apply in B?
Using powerpc-linux-gnu-g++ (Sourcery G++ Lite 4.3-74) 4.3.2
Note: I know that deprecated Indicates that the name or entity declared with this attribute is deprecated, that is, the use is allowed, but discouraged for some reason.

Related

c++11 pugixml fpclassify() warning float-converstion from double to float may alter its value

I am using c++11 and using a (or the) pugixml c++ library. I am compiling the pugi files myself (1 .cpp file, and 2 .hpp files).
When using gcc on linux (ubuntu) it builds fine. When I build with a different x-compiler I get warnings (probably due to different architecture / integral sizes).... fair enough so far.
My problem is that I want to fix the warnings because I am using -Werror throughout my code / makefile and I have lots of warnings turned on.
The specific line of code in the pugixml library is as followins (its an ~12k line file):
#elif defined(fpclassify) && defined(FP_NAN)
return fpclassify(value) == FP_NAN
#else
Where value is a double. The error I get is:
conversion to 'float' from 'double' may alter its value [
-Werror=float-conversion ]
This seems to fix it: return fpclassify(static_cast<float>(value)) == FP_NAN
But what I can't see (other then because the compiler tells me) is what fpclassify() and FP_NAN are. I can see some documentation here and here. It seems to show that there is a version of fpclassify for float and double.... so I am confused as to why there are warnings...
The x-compiler I am using is: arm-poky-linux-gnueabi-gcc version 5.2.0. which seems to support c++11.
I am looking for the reason why I get this warning. I can't really make a minimal example but if there is any further info that would be useful I can post it...

Mingw Disable Classes/Functions/Types Marked Deprecated?

Currently i have a problem with the deprecated messages flooding my output and i want to stop it without disabling all deprecated messages. It is warning me about auto_ptr (which i don't even use in my own code). Even if it can't be done with a compiler flag, the std library looks like it could disable it, though i couldn't find out how:
#if _GLIBCXX_USE_DEPRECATED
template<typename> class auto_ptr;
#endif
You probably selected the -std=c++11 or -std=c++0x language dialect, or it's your GCC versions default setting.
std::auto_ptr is marked as deprecated with the current standard, in favor of the c++11 smart pointers from the dynamic memory management library.
" (which i don't even use in my own code)."
Are you sure that you don't even include any 3rd party (non standard) stuff, that might make use of std::auto_ptr<>?
"the std library looks like it could disable it, though i couldn't find out how"
Just make sure that this flag (_GLIBCXX_USE_DEPRECATED) is undefined, when compiling your code:
$ g++ -U_GLIBCXX_USE_DEPRECATED ...

How do you make the warning come up that has the words 'suspicious' and '-Wmain' in it?

It's a simple question really, and refers to Linux (as opposed to Windows or Mac).
How do you generate a warning message from the C or C++ compiler that must have the word 'suspicious' in it, and must refer to (-Wmain).
(update)
Thanks Boann - I got some of those Warnings, but I also got Error - error: ‘::main’ must return ‘int’.
The reason I'm asking this question is that a week ago my compiler (GCC 4.8.1) came out with this warning saying 'suspicious' and that it was caused by Wmain. So I put -Wno-main and the warning went away and it compiled fine. Just recently it has started complaining making it an actual Error and not compiling. So I'm kind of worried that somehow the mother ship has covertly updated my compiler over the internet, without me knowing, and changed it to treat it as error. (I was probably using 'int4' as the return type which I forever have typedef'd as signed long int.
I note there's -Wmain referenced in g++ man page so it must be for something, but what warning is there that isn't overruled by an error??
At offset 557284 (decimal) of the g++ executable I found "Warn about suspicious declarations of "main".
For what it's worth,
struct suspicious {};
int main(suspicious) {}
Output with g++ -Wall, GCC 4.8.2:
warning: first argument of 'int main(suspicious)' should be 'int' [-Wmain]
If you refer to the -Wmain parameter of GCC, you get the warning by giving main odd arguments, an odd return type, or giving it static linkage. This will do it:
static float main(float x) {
return 0;
}
Compiled with gcc -Wmain, it displays these warnings; they do not actually contain the word 'suspicious' though:
warning: return type of 'main' is not 'int'
warning: first argument of 'main' should be 'int'
warning: 'main' takes only zero or two arguments
warning: 'main' is normally a non-static function
I just downloaded the sources for gcc 4.8.1 and searched all relevant files for the word "suspicious".
There are a number of occurrences, but as far as I can tell, there's no way an error message for a C or C++ source file can contain the word "suspicious". It's possible but unlikely that there was a local modification.
Is it possible that you're mistaken about what the error message said? If you have a log containing the error message, please update your question to show the exact message your received.
If you're concerned that your compiler may have been updated without your knowledge, you might check the timestamp of the compiler executable and of any programs it invokes (use gcc -v to check that). But gcc itself doesn't automatically update itself. If you're using it on a system administered by someone else, automatic updates are to be expected. If you administer the system yourself, you may have configured it to update software without manual intervention; if so, that's not a gcc issue. I don't know what "mother ship" you're referring to.

ImageMagick pthread.h multiple definition

When trying to compile more recent versions of ImageMagick (v6.8.7-2 or later, v6.8.7-1 is fine), I get a bunch of:
CCLD magick/libMagickCore-6.Q16.la
magick/.libs/magick_libMagickCore_6_Q16_la-animate.o: In function `__pthread_cleanup_routine':
/usr/include/pthread.h:581: multiple definition of `__pthread_cleanup_routine'
magick/.libs/magick_libMagickCore_6_Q16_la-accelerate.o:/usr/include/pthread.h:581: first defined here
magick/.libs/magick_libMagickCore_6_Q16_la-annotate.o: In function `__pthread_cleanup_routine':
/usr/include/pthread.h:581: multiple definition of `__pthread_cleanup_routine'
magick/.libs/magick_libMagickCore_6_Q16_la-accelerate.o:/usr/include/pthread.h:581: first defined here
magick/.libs/magick_libMagickCore_6_Q16_la-artifact.o: In function `__pthread_cleanup_routine':
/usr/include/pthread.h:581: multiple definition of `__pthread_cleanup_routine'
magick/.libs/magick_libMagickCore_6_Q16_la-accelerate.o:/usr/include/pthread.h:581: first defined here
magick/.libs/magick_libMagickCore_6_Q16_la-attribute.o: In function `__pthread_cleanup_routine':
/usr/include/pthread.h:581: multiple definition of `__pthread_cleanup_routine'
magick/.libs/magick_libMagickCore_6_Q16_la-accelerate.o:/usr/include/pthread.h:581: first defined here
... goes on for quite a bit longer, all the same.
The pertinent area of /usr/include/pthread.h (from glibc-headers 2.5-118.el5_10.2) is:
/* Function called to call the cleanup handler. As an extern inline
function the compiler is free to decide inlining the change when
needed or fall back on the copy which must exist somewhere else. */
extern __inline void
__pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame)
{
if (__frame->__do_it) // <======= this is :581
__frame->__cancel_routine (__frame->__cancel_arg);
}
I've been posting on ImageMagick's forum without response.
Even if you can't say exactly what's happening, how do I start figuring out whether the issue is with ImageMagick or pthread.h? Where do I go from there?
grep pthread_cleanup_routine -r * only shows matches against the binary object files -- none of ImageMagick's source code has pthread_cleanup_routine in it. A few of the sources include "pthread.h" of course.
That's leading me to believe that this is a glibc issue, not an ImageMagick issue... but, again, previous versions of ImageMagick compile just fine. (I have diff'ed the svn sources between versions where it broke. Lots of configuration/makefile changes, but nothing sticks out to me as to why it would cause this.)
I'm on CentOS 5, kernel 2.6.18-308.24.1.el5, gcc v4.9.0, ld v2.24, glibc-headers 2.5-118.el5_10.2
I've seen a lot of people posting similar issues with other packages than ImageMagick. Hopefully others will find this useful.
Changing pthread.h, just before __pthread_cleanup_routine :
extern __inline void
to
if __STDC__VERSION__ < 199901L
extern
#endif
__inline void
Fixes the issue. Older versions of glibc had an issue when -fexceptions was used, and inline non-C99 conformance (see http://gcc.gnu.org/ml/gcc-patches/2006-11/msg01030.html.) More recent glibc's would fix the issue too, but this should be a temp fix for those who don't want to / shouldn't upgrade it.
ImageMagick svn 13539 (which later became v6.8.7-2) began using -fexceptions.
I faced this error with a newer gcc compiler (4.9.3)
The ImageMagick(6.8.9_7) configure script was checking if compiler supports gnu99 standard. If yes, the configure script sets standard to gnu99 and also enables openmp.
Inline semantics change with C standard gnu99 causing multiple definition of the extern inline function
https://gcc.gnu.org/onlinedocs/gcc-4.9.3/gcc/Inline.html#Inline.
So, I added compiler flag -fgnu89-inline to use older semantics for inline and it fixed the issue.

How to fix "error: no previous declaration for void awn::vala_array_destroy"?

I'm on Ubuntu 13.04 32 platform. I'm trying to compile awn with latest vala. I get following error message.
vala-utils.cc: In function 'void awn::vala_array_destroy(gpointer, gint, GDestroyNotify)':
vala-utils.cc:358:6: error: no previous declaration for 'void awn::vala_array_destroy(gpointer, gint, GDestroyNotify)' [-Werror=missing-declarations]
cc1plus: some warnings being treated as errors
How can I fix that error?
At the top of vala-utils.cc insert the function prototype:
void vala_array_destroy(gpointer array, gint array_length, GDestroyNotify destroy_func);
This will silence the warning which is causing the build to fail due to -Werror defined in the Makefile. Consider raising a pull request for the benefit of the maintainers.
Alternatively modify ln.89 in configure.ac and remove the -Werror to stop the warning failing the build.
This actually a warning, and a rather pedantic one at that.
It's saying that the global function awn::vala_array_destroy has not been declared beforehand. Usually this is a sign of a programmer's mistake, but from the source it seems to me that:
this function is only supposed to be used by awn::vala_array_free directly below it (in which case it should really have been given internal linkage), or
a declaration is available in some header elsewhere (in which case it's probably in the wrong header, as it ought to be in vala-utils.h).
The long and short of it is that the code is probably fine, if a little strangely designed. This case is being treated as an error because you have -Werror turned on for this warning, turning it into an error.
I don't know how you're building the library, but you could adjust the compiler flags to avoid this; by default, GCC does not emit this warning, nor turn it into an error. Alternatively, you could add the function declaration into vala-utils.h yourself. You should also take up the issue with the library's maintainers.
Update: I found the culprit on line 89 of AWN's configure.ac. You should definitely take this up with the library maintainers. I'd be amazed if this had not already been reported as a bug; I believe it was introduced in this revision.