![]() |
| | #1 |
| Registered User Join Date: Jun 2009
Posts: 4
| lvalue required as increment operand compile error Code: int
read_itr_seq(void *buf, int itype, FILE *f)
{
int l, ch;
void *p = buf ;
if ( itype < 7 || (itype > 13 && itype != 20) ) return -2 ;
l = (ch = getc(f)) ;
if ( l == 0 ) {
while ( (ch = getc(f)) == 0 ) ;
ch = getc(f) ; /* Second byte of chunk word */
l = (ch = getc(f)) ;
}
else if ( ch == 0xff ) return 0 ;
*((u_char *)p)++ = l ;
if ( itype < 11 || itype == 20 ) fread(p, (size_t)(l + 22), (size_t)1, f) ;
else fread(p, (size_t)(l + 23), (size_t)1, f) ;
if ( ferror(f) ) return -1 ;
return 1 ;
}
Code: *((u_char *)p)++ = l ; |
| canadatom is offline | |
| | #2 |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| I'm gonna guess that is better written as Code: *(p++) = l ;
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS Last edited by MK27; 06-13-2009 at 11:11 AM. |
| MK27 is offline | |
| | #3 | ||
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,352
| hmm... you cast p to a u_char*, assign l to the u_char that this temporary pointer points to, then increment this temporary pointer. The increment is not useful, so it should suffice to write: Code: *(u_char *)p = l ; Quote:
EDIT #2: Quote:
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way Last edited by laserlight; 06-13-2009 at 11:20 AM. | ||
| laserlight is online now | |
| | #4 |
| Registered User Join Date: Jun 2009
Posts: 4
| thanks for helping guys, *(u_char *)p = l; works for me, and Code: int
extract_text_nosource(char *ip, int il, FIELD_TYPE field_type,
Extraction_regime reg, int (*stemfn)(char *, int, char *),
Gsl *gs, void *outptr, int outflag, int rec, int diag)
{
int l = il ;
char *p = ip ;
char *sp ;
int pl, sl ;
int nk ;
int numterms = 0 ;
int stopped ;
int outlen ;
void *opp = outptr ;
while ( l > 0 ) {
pl = find_para(p, l, INDENT|GAP) ;
stopped = 0 ;
l -= pl ; sp = p ; p += pl ;
while ( pl > 0 ) {
sl = find_sentence(sp, pl, field_type, TEXTPOS_MAX_T, 0) ;
nk = extract(sp, sl, reg, gs, stemfn, opp, outflag,
rec, 0, 0, 0, (int *)NULL, &stopped, &outlen) ;
if ( nk == -1 ) {
numterms = nk ;
break ;
}
pl -= sl ;
sp += sl ;
numterms += nk ;
(char *)opp += outlen ;
}
}
return numterms ;
}
Code: (char *)opp += outlen ; Thanks again for helping here Last edited by canadatom; 06-13-2009 at 11:29 AM. |
| canadatom is offline | |
| | #5 |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,352
| It's the same problem: from what I infer, the C standard now states that the result of a cast expression may not be used as an lvalue, i.e., it may not be modified. This makes sense, since the result of a cast expression is a temporary that would typically end its lifetime after the given statement. So, this statement: Code: (char *)opp += outlen ; In this case, it looks like opp should just be a pointer to char to begin with.
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way |
| laserlight is online now | |
| | #6 |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| So make opp a char* and cast it to void where necessary. ps. they don't call you "Stompin'", do they?
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS |
| MK27 is offline | |
| | #7 |
| Registered User Join Date: Jun 2009
Posts: 4
| any hint for this line to be able to compile? Thanks |
| canadatom is offline | |
| | #8 | |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,352
| Quote:
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way | |
| laserlight is online now | |
| | #9 |
| Registered User Join Date: Jun 2009
Posts: 4
| thanks a lot for helping : ) |
| canadatom is offline | |
![]() |
| Tags |
| compile error, gcc, linux |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how do you resolve this error? | -EquinoX- | C Programming | 32 | 11-05-2008 04:35 PM |
| Another syntax error | caldeira | C Programming | 31 | 09-05-2008 01:01 AM |
| Post... | maxorator | C++ Programming | 12 | 10-11-2005 08:39 AM |
| Dikumud | maxorator | C++ Programming | 1 | 10-01-2005 06:39 AM |
| Please Help - Problem with Compilers | toonlover | C++ Programming | 5 | 07-23-2005 10:03 AM |