Problems Compiling

Posted by Kelven on Sun 02 Sep 2001 10:43 PM — 8 posts, 27,069 views.

#0
I downloaded Smaug1.4a for Windows from this site, and it doesn't seem to want to compile.

I am attempting to compile it with Cygwin beta19.
I've used this version of Cygwin to compile a ported version of smaug1.4 many times before without any trouble.

With the smaug1.4a for Win32 that I've downloaded from Nick Gammon's site, it gives me a few parse errors. I've looked over the code and I honestly can't see why it's giving me those errors. I am not the best coder, however, so I'm probably missing something.

I thought I'd ask for help here first since this is where I got the code.

The error appears in interp.c at 1192 and 1197
1192: parse error before '<'
1197: parse error before 'if'

The code:

1187 void update_userec(struct timeval *time_used, struct 1188 timerset *userec)
1189 {
1190 userec->num_uses++;
1191 if ( !timerisset(&userec->min_time)
1192 || timercmp(time_used, &userec->min_time, <) )
1193 {
1194 userec->min_time.tv_sec = time_used->tv_sec;
1195 userec->min_time.tv_usec = time_used->tv_usec;
1196 }
1197 if ( !timerisset(&userec->max_time)
1198 || timercmp(time_used, &userec->max_time, >) )
1199 {
1200 userec->max_time.tv_sec = time_used->tv_sec;
1201 userec->max_time.tv_usec = time_used->tv_usec;
1202 }
1203 userec->total_time.tv_sec += time_used->tv_sec;
1204 userec->total_time.tv_usec += time_used->tv_usec;
1205 while ( userec->total_time.tv_usec >= 1000000 )
1206 {
1207 userec->total_time.tv_sec++;
1208 userec->total_time.tv_usec -= 1000000;
1209 }
1210 return;
1211 }

If anyone can help me, I'd really appreciate it. Thanks :)
Australia Forum Administrator #1
There is a solution to this in another post. It is handy when you have a query like that to use the search feature (at the bottom of each page) and try searching for keywords which seem relevant to your problem.

In this case keywords would be "interp.c and timercmp" so you could put that into the search.

The first results returned when I did that mentions a change to interp.c relating to time, namely:


In interp.c:



#define __rtems__ // <--- Add this
#include <time.h> // <--- before this line


What this effectively does is add a "define" for "timercmp" which lets it process the offending line correctly.
Amended on Sun 02 Sep 2001 10:53 PM by Nick Gammon
#2
Hmm, I added that line and it gives me the same error.

Could it be because of the compiler I'm using? I read that you compiled this code successfully with MS C++ 6.0.
Australia Forum Administrator #3
Those instructions were for Cygwin, not MS C++.

Make sure you put the line in exactly (copy and paste). That is two underscores on each side, not one.

Also, it has to go before the include mentioned, or nothing will happen.
Amended on Sun 02 Sep 2001 11:10 PM by Nick Gammon
#4
It was inserted exactly as written.
I read in a previous post that Smaug1.4a Win32 shouldn't be compiled with Cygwin, that the Smaug1.4a for Unix will work when compiled with Cygwin.

Perhaps I should try to compile 1.4a Unix instead?
#5
Downloaded and tried the non-win port of 1.4a, exact same problem (even after I changed the code)

It appears 1.4a doesn't like me.

Perhaps because I've been on rot muds for the past year, I've made all smaug codebases hate me :\
#6
Can anyone help? I tried compiling both 1.4a Win32 and 1.4a Unix with cygwin, both give me the same error (even after I change the code to how Nick stated above)

Is there another copy of smaug 1.4a that can compile with cygwin successfully that I could get?

I don't mean to be a pest, I just want to be able to compile 1.4a with cygwin.
Australia Forum Administrator #7
Try this.

Change directory to /usr/include/sys and edit the file time.h.

At around line 83, change it like this:


/* BSD time macros used by RTEMS code */
//#if defined(__rtems__)
#if 1

/* Convenience macros for operations on timevals.
NOTE: `timercmp' does not work for >= or <=. */
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)



This will force the timer macros (eg. timercmp) to be compiled in.