Domanda

I am new in c++. I am compiling a code source on Qt. I have this warning:

In file included from ../ListAllPrsilicaCameras/main.cpp:3: In file included from /usr/include/c++/4.2.1/backward/iostream.h:31: /usr/include/c++/4.2.1/backward/backward_warning.h:32:2: warning: This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated. [-W#warnings]

#warning This file includes at least one deprecated or antiquated header.

^ 1 warning generated


I got also these warning:

../ListCamerasProsilicaII/main.cpp:79:51: warning: unused parameter 'junk' [-Wunused-parameter]
void SetConsoleCtrlHandler(void (*func)(int), int junk)
                                                  ^
../ListCamerasProsilicaII/main.cpp:89:23: warning: unused parameter 'Signo' [-Wunused-parameter]
void CtrlCHandler(int Signo)
                      ^
../ListCamerasProsilicaII/main.cpp:140:57: warning: flag ' ' results in undefined behavior with 'u' conversion specifier [-Wformat]
                        printf("%s - %8s - Unique ID = % 8lu IP@ = %15s [%s]\n",cameraList[i].SerialString,
                                                       ~^~~~
../ListCamerasProsilicaII/main.cpp:147:57: warning: flag ' ' results in undefined behavior with 'u' conversion specifier [-Wformat]
clang++ -headerpad_max_install_names -mmacosx-version-min=10.6 -o ListCamerasProsilicaII main.o   -L/opt/local/lib/ -lPvAPI -lPvJNI -L/opt/local/lib -lJPEG -F/Users/rafikgouiaa/Qt//5.0.2/clang_64/lib -framework QtCore 
                        printf("%s - %8s - Unique ID = % 8lu (unavailable, %u)\n",cameraList[i].SerialString,
                                                       ~^~~~
../ListCamerasProsilicaII/main.cpp:152:53: warning: flag ' ' results in undefined behavior with 'u' conversion specifier [-Wformat]
                    printf("%s - %8s - Unique ID = % 8lu (*)\n",cameraList[i].SerialString,
                                                   ~^~~~
../ListCamerasProsilicaII/main.cpp:171:14: warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, char* argv[])
             ^
../ListCamerasProsilicaII/main.cpp:171:26: warning: unused parameter 'argv' [-Wunused-parameter]
int main(int argc, char* argv[])
                         ^
7 warnings generated.

How can I disable this warning ?

È stato utile?

Soluzione

Repeating the previous answer "The answer is in the warning message itself."

"To disable this warning use -Wno-deprecated."

You can specify the compiler flag in the Qt project file (.pro) adding this line:

QMAKE_CXXFLAGS += -Wno-deprecated

P.S. It will be better to fix the code itself

Altri suggerimenti

The answer is in the warning message itself:

EDIT:

warning: This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated. [-W#warnings]

replace iostream.h by iostream C++'s headers nowadays didn't require .h extension anymore.


warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, char* argv[])
             ^
warning: unused parameter 'argv' [-Wunused-parameter]
int main(int argc, char* argv[])

Change the definition of main in:

int main()
{
  // ...

it's standard compliant.


warning: unused parameter 'junk' [-Wunused-parameter]
void SetConsoleCtrlHandler(void (*func)(int), int junk)

Not naming a parameter is legal also in function implementation. This is useful when the function needs to declare the parameter to have a specific fixed signature, but the parameter is not needed (this may happen for example for a method in a derived class, for a callback function or for a template parameter).

So, if this is the case, you could change the function definition:

void SetConsoleCtrlHandler(void (*func)(int), int)
{
  //...

If you control the header file, fix it! For the ones you don't (system, 3rd party libs...) you can use the -isystem flag (this will make them "system headers" and GCC/CLANG won't report warnings for them).

E.g.

QMAKE_CXXFLAGS += -isystem ...
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top