Hi , can anyone tell me what does this error mean?
s\visual studio 2005\projects\igrabobi\igrabobi\Form1.h(124) : error C2451: conditional expression of type 'void' is illegal
I got it when I tried to build my game.
Thanks a lot

Recommended Answers

All 6 Replies

Try posting your code.

From the looks of it, you're trying to use a conditional expression on a function that doesn't return anything.

Again, it's a wild-out-of-the-backside guess, so post your code so we can confirm the real issue.

It means what it says. Post code because I can't see your monitor.

Google is very nice:

As others have said, post code, but this, or something like it, would cause the problem you're having:

void Func()
    cout << "I am a function.\n";

int main()
    if(Func())//Func() returns nothing - you can't check if a nonexistent result is true or false
        cout << "Helllo.\n";

    return 0;

Well here is a part of my code, 'cause you know the Visual Studio generates it's own code, so i copied the code that I wrote. I am a beginner, a "rookie", so don't mind me askng for easy things :)

#pragma endregion
	private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
	private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
				 if (textBox1->Text="Filip")

>>if (textBox1->Text="Filip")
My guess is the above line is wrong. textBox1 can not be used in an if condition like that. Change the = operator to == and see if that fixes it.

Yeah, that helped a lot. Thanks a lot, I can now continue making my history game :) Thanks again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.