0

I get the error I mentioned in the title when I try to compile the following code:

void Sql::select(const string table, const string column, const string condition, const string condition_2, const string condition_3) {
otl_stream s;
otl_column_desc* desc;
int desc_len;

const string select = str(format("SELECT %2% FROM %1% WHERE LEFT(%3%, 8) < %6% AND %4% = 'Ausstehend' AND (%5% = '1' OR %5% = '2') ")
        % table % column % condition % condition_2 % condition_3 % getDate());

// cout << select;
    try {
        s.open(10, select.c_str(), con);
    } catch (otl_exception &e) {
        cerr << e.msg;
    }

desc = s.describe_select(desc_len);

}

I am told that otl_column_desc* desc is set but not used. Can you tell me what goes wrong there?

FRules
  • 739
  • 1
  • 10
  • 20
  • 1
    You're capturing the return value of s.describe_select in "desc", but you're not then using desc for anything. You might as well drop this return value on the ground, if you don't mean to use it. – crowder Jun 26 '13 at 05:26

1 Answers1

0

Its exactly what it says, you are setting the variable but not using the value anywhere, meaning this variable is, for all intents and purposes, useless.

desc = s.describe_select(desc_len);//value in desc never used

This sometimes could happen if you make a mistake in your code, and use some other variable when you meant to use this one, and I guess this warning is to catch those cases.

But to answer your question, nothing is wrong since this is a warning, not an error. It is just an indication that something might be wrong.

Karthik T
  • 31,456
  • 5
  • 68
  • 87
  • Wowowow, okay, so a cout << desc would be enough, to get rid of that error? I used to get just warnings in Java when I did that, not errors as in C++. Thank you! – FRules Jun 26 '13 at 05:28
  • @DominikNitschmann This is just a warning. I believe that the flag you mention might force warnings into errors. The better way would be to remove it if you don't need such a variable. – Karthik T Jun 26 '13 at 05:29
  • @DominikNitschmann I think this should just be a warning. The flag just seems to enable the warning, and not make it an error – Karthik T Jun 26 '13 at 05:31
  • @DominikNitschmann, a `cout` is certainly one way to use it but it seems a bit silly to do that to remove the warning when you can just gid rid of desc altogether, since (and forgive my bold) **YOU DO NOT USE IT!!** :-) – paxdiablo Jun 26 '13 at 05:31