This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Mysterious syntax error
- From: "Dave Gotwisner" <Dave dot Gotwisner at harmonicinc dot com>
- To: "Ian Pilcher" <i dot pilcher at comcast dot net>, <gcc-help at gcc dot gnu dot org>
- Date: Wed, 26 Jan 2005 17:39:13 -0800
- Subject: RE: Mysterious syntax error
I am not sure where your file was generated, and can't tell from the
listing (it looks correct), but if the file was initially generated on
Windows and binary ftp'ed over to a Unix box before it was compiled,
there might be a ^Z at the end of the file (or a '\0'). If you OD -x
the source and look at the output at the end, it should be glaringly
obvious. Also, I have seen some compilers barf if there is no \n at the
end of the last line, not sure how GCC behaves (it used to croak, years
ago).
-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Ian Pilcher
Sent: Wednesday, January 26, 2005 5:25 PM
To: gcc-help@gcc.gnu.org
Subject: Mysterious syntax error
Apologies in advance if this is a *really* stupid question. I'm trying
to compile the code below on Fedora Core 3 (gcc-3.4.2-6.fc3), and it's
telling me I've got a syntax error that I just can't see.
[pilcher@home temp]$ gcc -c aarg.c
aarg.c: In function `alarm_thread':
aarg.c:82: error: syntax error at end of input
I've stared at this long enough to know that, if there is an error in
the code, I'm not going to find it. I'd really appreciate it if someone
with smarter eyes could take a look.
Thanks!
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/time.h>
typedef struct pt_alarm_s pt_alarm_t;
typedef struct pt_alarmattr_s pt_alarmattr_t;
enum pt_alarm_state
{
PT_ALARM_IDLE,
PT_ALARM_SET,
PT_ALARM_RUNNING,
PT_ALARM_CANCELED,
PT_ALARM_ERROR
};
struct pt_alarm_s
{
pthread_t target_tid;
pthread_t alarm_tid;
pthread_mutex_t mutex;
pthread_cond_t cond;
struct timespec timeout;
enum pt_alarm_state state;
};
struct pt_alarmattr_s
{
unsigned char filler[1];
};
/***********************************************************************
*
* alarm thread
*
**********************************************************************/
static void cleanup_alarm_mutex(void *arg)
{
pt_alarm_t *const alarm = arg;
pthread_mutex_unlock(&alarm->mutex);
}
static void *alarm_thread(void *arg)
{
pt_alarm_t *const alarm = arg;
pthread_cleanup_push(cleanup_alarm_mutex, arg);
pthread_mutex_lock(&alarm->mutex);
while (1)
{
int pt_errno;
while (alarm->state != PT_ALARM_SET)
pthread_cond_wait(&alarm->cond, &alarm->mutex);
alarm->state = PT_ALARM_RUNNING;
pt_errno = 0;
while (alarm->state != PT_ALARM_CANCELED &&
pt_errno != ETIMEDOUT)
{
pt_errno = pthread_cond_timedwait(&alarm->cond,
&alarm->mutex, &alarm->timeout);
}
if (alarm->state != PT_ALARM_CANCELED)
pthread_kill(alarm->target_tid, SIGALRM);
}
return NULL; /* should never get here! */
}
--
========================================================================
Ian Pilcher i.pilcher@comcast.net
========================================================================