简体   繁体   中英

Error “void value not ignored as it ought to be” in C programming

This is a part in my code:

Type* compileExpression2(void) {
    Type* type1;
    Type* type2;
    type1 = compileTerm();
    type2 = compileExpression3();
}

Type* compileExpression3(void) {
    Type* type1;
    return type1;
}

Type* compileTerm(void) {
    // TODO: check type of Term2
    Type* type;
    type = compileFactor();
    compileTerm2();
    return type;
}

I used Code::Blocks to build it and it returned this error:

void value not ignored as it ought to be

at the line:

type2 = compileExpression3();

Please tell me why.


Thanks you very much for all your answers. I've found out my problem.

Is is in my include file, compileExpression3 had been declared as "void compileExpression3(void);"

By elimination, it's likely compileTerm returns void .

EDIT

You added compileTerm but now compileFactor is missing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM