CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2009
    Location
    Boston
    Posts
    364

    -Wno-unused-varialbe flag has no effect

    Hello,

    I have an application that I just brought into eclipse. I have previously just built this application from the command line. I am looking to suppress some warnings in the short term but find this is not entirely working.

    In the make file,
    Code:
    # add linux version flag to CFLAGS
    ifeq "$(CC++)" "g++"
       CFLAGS =  $(OPTIMIZE)  -DLINVGCC4 -DDATESTR=$(DATESTR2) $(DEFRELS) -I src -Wall
    endif
    
    # supress some c++ warnings
    #CFLAGS := $(CFLAGS) -Wno-sign-compare -Wno-unused-variable
    The -Wno-sign-compare flag works and I don't get these warnings. I am still getting the unused-variable warnings, so I don't understand what I am missing here.

    This is g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), CentOS 7.7, built in Eclipse 20191212-1212, using a gnu makefile.

    Thanks,

    LMHmedchem
    Last edited by LMHmedchem; January 25th, 2020 at 01:57 PM.

  2. #2
    Join Date
    Nov 2018
    Posts
    121

    Re: -Wno-unused-varialbe flag has no effect

    Was it the switch from using = to using := in your assignments?

    Makefiles can be very picky things when it comes to evaluating variables, and the two forms mean two very different things.

  3. #3
    Join Date
    May 2009
    Location
    Boston
    Posts
    364

    Re: -Wno-unused-varialbe flag has no effect

    Quote Originally Posted by salem_c View Post
    Was it the switch from using = to using := in your assignments?

    Makefiles can be very picky things when it comes to evaluating variables, and the two forms mean two very different things.
    I always use := when adding to a variable that has already been assigned.

    I would do,
    Code:
    # set for most warnings
    CFLAGS = -Wall
    # add to CFLAGS to supress some warnings in all
    CFLAGS := $(CFLAGS) -Wno-sign-compare
    if I wanted to add something to CFLAGS after it has been defined and assigned some value.

    My understanding is that this will simply expand $(CFLAGS) before assigning it back along with the additions. If this is not the correct method, I would appreciate some feedback on that.

    It does seem to be working now. When I added the no-sign-compare flag, it seemed to not do anything until I had rebuilt several times.

    LMHmedchem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured