-1

I receive this warning when compiling my program.

In member function 'bool CClientManager::InitializeMobTable()':
warning: variable 'isNameFile' set but not used [-Wunused-but-set-variable]
bool isNameFile = true;
     ^

Here is the relevant part of my code

bool CClientManager::InitializeMobTable()
{
        map<int,const char*> localMap;
        bool isNameFile = true;


        cCsvTable nameData;
        if(!nameData.Load("mob_names.txt",'\t'))
        {
                fprintf(stderr, "mob_names.txt 파일을 읽어오지 못했습니다\n");
                isNameFile = false;
        } else {
                nameData.Next();
                while(nameData.Next()) {
                        localMap[atoi(nameData.AsStringByIndex(0))] = nameData.AsStringByIndex(1);
                }
        }
        // More ...
 }

I put the rest on pastebin because is too big: http://pastebin.com/HrVLimgn

The warninig is on 170 Line in that file on pastebin.

My question is, how can I fix? If you comment these lines with a bit affects my program?

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Freaksy
  • 41
  • 1
  • 4

1 Answers1

1

"My question is, how can I fix?"

You can put a

(void)isNameFile;

statement after the initialization to get rid of the warning, or simply remove the

bool isNameFile = true;

and

isNameFile = false;

lines, if the variable isn't used and won't be further (if it's not used because of some temporarily commented code).

"If you comment these lines with a bit affects my program?"

It shouldn't affect your program if you remove or comment that line. The variable isn't used (accessed) other than assigning it elsewhere. That's what the warning says.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
  • Look at this: http://prntscr.com/7bgbu4 If i comment bool isNameFile = true; Then give me error on this http://prntscr.com/7bgcx4 if i remove that line, then say line 177 is not declared in this scope. – Freaksy May 31 '15 at 12:16
  • 2
    you can delete both, it is not used thus doesnt change anything in your program, nothing depends on that variable – lllook May 31 '15 at 12:25
  • 1
    @Freaksy The variable is only assigned but never read, that's what the warning says. – πάντα ῥεῖ May 31 '15 at 12:40