Home > OS >  warning: value computed is not used [-Wunused-value]
warning: value computed is not used [-Wunused-value]

Time:02-20

How can I solve this warning?

CODE:

#define tofile(L,i) (tofileh(L,i)->f)
static FileHandle *tofileh (lua_State *L, int findex) {
  FileHandle *fh = topfile(L, findex);
  if (fh->f == NULL)
    luaL_error(L, "attempt to use a closed file");
  return fh;
}

I have no idea about this warning. points to this line;

(tofileh(L,i)->f)

CodePudding user response:

In (tofileh(L,i)->f), after the function returns a value, ->f evaluates the member f. This evaluation has no effect. It is not used in an assignment or a print operation or in anything else where it would do anything.

Evaluating an expression with no effect is often a sign of a mistake in source code, so the compiler warns you. To fix it, change the code to do something useful. The question does not provide sufficient context to determine why this source code is present, so advice cannot be given on what should be done instead.

  •  Tags:  
  • c
  • Related