0

In my code there is around 500 "unreferenced formal parameter", I need to suppress them, I got include guards but I need to do it for 5oo times, can anyone suggest the macro to suppress these warnings.

(void)status;

hCVar* 
pTmpVar = (hCVar *)pIB;

This is one among many.

A macro that can suppress all of them. How can I do so?

john
  • 85,011
  • 4
  • 57
  • 81
  • How about just disabling the warning itself? – Some programmer dude Feb 13 '19 at 06:55
  • 1
    `#pragma warning (disable: XXXX)` where XXXX is the number of the warning (I forget what it is). But in C++ you can also remove the parameter name (and just leave the type), that's probably the more correct thing to do. – john Feb 13 '19 at 06:56
  • can you suggest me in c make ,thank you for suggestion – pramod madinapalli Feb 13 '19 at 07:00
  • @pramodmadinapalli If your question is about C it should be tagged as C not C++. You can't remove the parameter name in C, but the `#pragma` should still work. – john Feb 13 '19 at 07:01
  • no bro cmake not c language,see i am making my project platform independent by using cmake and needed of macro to disable all this warnings – pramod madinapalli Feb 13 '19 at 07:08
  • Why don't you show a short snippet that triggers the warning and also exactly the warning that you get? Are you writing C or C++ (the tags say C!?)? – Werner Henze Feb 13 '19 at 07:11
  • if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D-Wno-unused-parameter) add_definitions(-D-Wno-unused-variable) add_definitions(-D-Wno-unreferenced-formal-parameter) – pramod madinapalli Feb 13 '19 at 07:14
  • this is the way i try to give flags for compiler to suppress,but for unrefrenced formal parameter it is not working – pramod madinapalli Feb 13 '19 at 07:15
  • if(MSVC) # Force to always compile with W4 if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") endif() elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) # Update if necessary set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic") endif() – pramod madinapalli Feb 13 '19 at 07:17
  • 1
    Please put relevant stuff into the question, not into comments. `-D-Wno-unused-parameter` defines a macro named `-Wno-unused-parameter` which I bet is not a valid macro name. This looks like you try to emulate a gcc command line, but that does not work. – Werner Henze Feb 13 '19 at 07:21

1 Answers1

0

As john said:

A solution in the code is to

#pragma warning disable(4100)

(or other solutions or [[maybe_unused]] in C++17). You can also add /Wd4100 in the makefile to the compiler command line.

Werner Henze
  • 16,404
  • 12
  • 44
  • 69