Compile error

Posted by Robert Powell on Sun 22 Feb 2004 07:50 AM — 6 posts, 20,889 views.

Australia #0
I just payed for some hosting and upploaded my source and tryed to compile and got the following errors, i have know idea why this would happen but im guessing it has something to do with the compilers, im using the latest mandrake and the server is redhat, any assistance would be great. Oh they say that they have these copmpilers C/C++ Compiler: gcc 2.95.3 & gcc 3.3


locker.c:145: parse error befor `if'
locker.c:145 stray '\' in program



#if defined(KEY)
#undef KEY
#endif

#define KEY( literal, field, value )     \
				if ( !str_cmp( word, literal ) ) \
				{					\
				    field  = value;   \
				    fMatch = TRUE;   \
				    break;    \
				}
Amended on Sun 22 Feb 2004 07:53 AM by Robert Powell
Canada #1
Sounds like it might be from somewher above that, as I can't see anything wrong with what you have. You can try to simply put it all on one line, it looks ugly, but it may work.
Australia #2
here is a few lines above it


	fclose( fp );

        /* Total the weight of the contents */
        for( obj = ch->in_room->first_content; obj; obj = obj->next_content )
        {
            locker->holding = locker->holding + ( obj->weight * obj->count );
        }
    }
    
    return locker;
}

Australia #3
Would you beleive that i managed to fix it, it was spitting the dummy over the final } not having a backslash on it.

Thanks grevem for making me give it some pretty formatting
Australia Forum Administrator #4
You need to be cautious with the backslashes. You shouldn't need one on the last line, however more importantly, you must not follow them by a space.

eg.


#define blah blah \
  blah


will work, but


#define blah blah \(space here)
  blah


Will not work.
Australia #5
thanks nick for the clarification, i went back into my source backups and found that i had an errent <space bar> or 3 heh, as i do all of my coding locally, i missed this problem as my compiler seems to not be bothered by such slackness(even if the crappy code was written my resort mud). My host seems to be a lot more strict with the code tho, which i guess can only mean that i will hopefully crash less from my own sloppyness.