It Won't Compile?


furyhunter600

Still Fresh
Joined
Sep 29, 2006
Messages
21
So I'm getting back into programming stuff in C, and after about an hour of coding and no compiling and then compiling, I'm greeted with a single error (Both good -and- bad.):

CODE
In function 'SDL_main':
invalid lvalue in assignment
{Warning} large integer implicitly truncated to unsigned type
{Build error} {win\main.o} Error 1

So I'm thinking it might be something wrong with my init function. Turns out it's not, and there's something wrong in my SDL libraries itself? I'm using GPH's Gp2x SDK.

Source on request.

Help please o_o
 
Furyhunter said:
So I'm getting back into programming stuff in C, and after about an hour of coding and no compiling and then compiling, I'm greeted with a single error (Both good -and- bad.):

CODE
In function 'SDL_main':
invalid lvalue in assignment
{Warning} large integer implicitly truncated to unsigned type
{Build error} {win\main.o} Error 1

So I'm thinking it might be something wrong with my init function. Turns out it's not, and there's something wrong in my SDL libraries itself? I'm using GPH's Gp2x SDK.

Source on request.

Help please o_o
what version of gcc are you using?
 
Last edited by a moderator:
Well, crap. Sorry about that...

I found my stupidly common mistake again, this time taking a record 8 hours to find out what was wrong:
CODE
if ( system_init() = 0 ) system_endgame();


See it? See that one huge hellish mistake? Yes.

Now disregard this topic XD
 
Furyhunter said:
Well, crap. Sorry about that...

I found my stupidly common mistake again, this time taking a record 8 hours to find out what was wrong:
CODE
if ( system_init() = 0 ) system_endgame();
See it? See that one huge hellish mistake? Yes.

Now disregard this topic XD



been there, done that, but at least it works now :)
 
Last edited by a moderator:
Ouch... 8 hours...
Yes it's a common mistake and a bastard when you realise it has got you (again? lol)

= != == ;)

Just for anyone that can't spot the mistake the "=" (value assignment) operator has been used instead of the "==" (equivalence) operator meaning, in this case, that the value 0 was trying to be assigned to the function call, system_init()...
 
A lot of people will code backwards, so it catches this; personally, I can't stand the technique, but here you go:

if ( 15 = x ) {...

That would get caught by compiler, since you cannot assign to a constant.

ie:

if ( NULL = somefunc() ) { ...

if ( NULL = p ) { ...

etc.

After awhile it (= problem) doesnt' catch you often, but it will catch you :)

jeff
 
Of course some assignments in conditionals are reasonable.
if (f = fopen("gayporn.jpg", "rb"))
etc..
 
Dr_Ian said:
Of course some assignments in conditionals are reasonable.
if (f = fopen("gayporn.jpg", "rb"))
etc..
Ofcourse writing:
f = fopen("moreporn.jpg", "rb")
if (f)
is also fine.

also works fine. And I think GCC also does not complain on the following:
if ((f = fopen("porn.jpg", "rb")) != false)

And maybe not on this:
if ((f = fopen("porn.jpg", "rb")))
(But that could have been Visual studio 2007)


For everyone style there is a way. So use what you see fit :) there is no holy grail.
 
Last edited by a moderator:
Back
Top