|
|
| Invalid lvalue... |
|
jakerohs
Member #485
June 2000
|
I'm trying to get Allegro Sprite Editor to compile...using Allegro 4.2 (ASE is supposed to use 4.0.3). I've tried the pre-built executable but it disagrees with my 4.2 runtime. Anyways, that leaves me to do some tweaking in the ASE source to get it working. So far, so good, I've sorted out several trivial problems (such as ASE defining its own load_font function, even though Allegro has one with the same name) but I'm stuck on this error: 72: invalid lvalue in increment unsigned char *address; unsigned char value;
... Pointer arithmetic is one of my weak areas - any idea what's wrong with line 72? Alternatively, can anyone supply me with a compilable allegro 4.2 version of ASE? Or better still, a binary that works? |
|
A J
Member #3,025
December 2002
|
((unsigned short *)address)++ huh? your ++'ing an address ? ___________________________ |
|
GullRaDriel
Member #3,861
September 2003
|
And he is casting a u_char in a u_short before that. "Code is like shit - it only smells if it is not yours" |
|
_Dante
Member #7,398
June 2006
|
Quote: Pointer arithmetic is one of my weak areas Then you really shouldn't be creating suspect constructions like this. There's so many things wrong with this statement, it's hard to know where to start. Why are you casting a char to a short? You need to stop for a moment and figure out what it is that you're really trying to accomplish. You should probably separate the pointer arithmetic from the assignment as well, or you'll be kicking yourself when you come back later and try to figure out what that line of code actually does, since it's clear that you barely understand it now. ----------------------------- |
|
Steve++
Member #1,816
January 2002
|
You can't do that in one statement, because you can't apply pointer arithmetic of one type of pointer to another type of pointer, no matter how much you cast it. Try this: *((unsigned short *)address) = value; address += sizeof(unsigned short)/sizeof(unsigned char);
|
|
FMC
Member #4,431
March 2004
|
Quote: Then you really shouldn't be creating suspect constructions like this. There's so many things wrong with this statement, it's hard to know where to start. That code is from ASE, he didn't write it... [FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
|
_Dante
Member #7,398
June 2006
|
Quote: That code is from ASE, he didn't write it... Yeah, my bad. I was kind of feeding into the two previous comments. Nonetheless, that line is a fabulous example of how not to write C code. ----------------------------- |
|
spunit262
Member #5,545
February 2005
|
What is ASE |
|
jakerohs
Member #485
June 2000
|
I agree, this is a prime example of how not to code. Nonetheless, this is in the ASE source code. I have no idea how the author got this stuff to compile, but anyhoo... Quote: What is ase? Allegro Sprite Editor. I can't tell you any more about it since I haven't gotten it working yet. It looks to me like the author is trying to move the pointer along 2 bytes (size of an unsigned short) instead of 1 byte (for a char). On most platforms. Edit: Steve's code compiles fine (as it should). It just gets worse though - here's the next compilation error: ((unsigned char *)data->address) += data->image->w << data->shift; Ewwwwww Thanks for the help guys, but I give up. Allegro Sprite Editor is obviously someone's cruel joke, and I've fallen for it. You may all laugh at me now. |
|
miran
Member #2,407
June 2002
|
Quote: I've tried the pre-built executable but it disagrees with my 4.2 runtime. Then get yourself alleg40.dll. Quote: Allegro Sprite Editor is obviously someone's cruel joke, and I've fallen for it. Well, if it hasn't been updated since Allegro 4.0.3 stopped being the last stable version of Allegro, then it's also probably dead. -- |
|
A J
Member #3,025
December 2002
|
jake, your avatar seems to be flipped. ___________________________ |
|
|