Mail Archives: cygwin/2005/05/20/17:40:53
Splint parseerror with <pthread.h>
VERSION: Splint: 3.1.1
DESCRIPTION:
Every C code that imports <pthread.h> causes an unrecoverable parse error.
#include <pthread.h>
REPRODUCTION:
To reproduce the error:
write this file.c:
---
#include <pthread.h>
int main() { return 0; }
---
then 'splint file.c'
Splint 3.1.1 --- 02 May 2003
/usr/include/pthread.h:75:43: Parse Error. (For help on parse errors, see
splint -help parseerrors.)
*** Cannot continue.
Splint 3.1.1 --- 02 May 2003
SOLUTION:
Explicitly define __CYGWIN__ flag for splint.
otherwise your system headers will not be processed right.
splint +D__CYGWIN__ file.c
LOG OF FIXING PROCEDURE:
USERS ARE NOT REQUIRED TO READ THIS.
INTENDED FOR DEVELOPERS AID.
# 15-may-2005:
in my installation, a grep -n into pthread.h at lines 70-80 looks:
70-#define PTHREAD_SCOPE_PROCESS 0
71-#define PTHREAD_SCOPE_SYSTEM 1
72-
73-
74-/* Attributes */
75:int pthread_attr_destroy (pthread_attr_t *);
76-int pthread_attr_getdetachstate (const pthread_attr_t *, int *);
77-int pthread_attr_getinheritsched (const pthread_attr_t *, int *);
78-int pthread_attr_getschedparam (const pthread_attr_t *, struct
sched_param *)
;
79-int pthread_attr_getschedpolicy (const pthread_attr_t *, int *);
80-int pthread_attr_getscope (const pthread_attr_t *, int *);
So the problematic row is
int pthread_attr_destroy (pthread_attr_t *);
where ')' is the 43-th char.
# 16 may 2005:
with other splint options:
$ splint +posixlib
$ splint +posixstrictlib
$ splint +trytorecover
remains the same, but with:
$ splint +posixlib +trytorecover
$ splint +posixstrictlib +trytorecover
the error shift to line 79:
Splint 3.1.1 --- 02 May 2003
/usr/include/pthread.h:79:56: Parse Error. Too many errors, giving up.
*** Cannot continue.
that is on character ',':
79-int pthread_attr_getschedpolicy (const pthread_attr_t *, int *);
So the error is clearly placed after a declaration of pointer pthread_attr_t
*.
Why complain about a ')' or ',' there?
What is Splint expecting there?
# 17 may 2005:
now a trip in sys/types.h, where you will find pthread_attr_t is defined as
a struct:
308-typedef struct {
309- int is_initialized;
310- void *stackaddr;
311- int stacksize;
312- int contentionscope;
313- int inheritsched;
314- int schedpolicy;
315- struct sched_param schedparam;
316-
317- /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute. */
318-#if defined(_POSIX_THREAD_CPUTIME)
319- int cputime_clock_allowed; /* see time.h */
320-#endif
321- int detachstate;
322-
323:} pthread_attr_t;
But this isn't true, sys/types.h don't define pthread_attr_t, in Cygwin!
Go up until a of a top-level
#if defined(_POSIX_THREADS) && !defined(__CYGWIN__)
with a meaningful comment:
/* Cygwin will probably never have full posix compliance due to little
things
* like an inability to set the stackaddress. Cygwin is also using void *
* pointers rather than structs to ensure maximum binary compatability with
* previous releases.
* This means that we don't use the types defined here, but rather in
* <cygwin/types.h>
*/
So, the real target is: grep -n pthread_attr /usr/include/cygwin/types.h
212:typedef struct __pthread_attr_t {char __dummy;} *pthread_attr_t;
ok, it's a dummy one, but I don't see language-specific errors here.
# 19 may 2005:
!!!!CATCHED!!!!
I re-read the directive
#if defined(_POSIX_THREADS) && !defined(__CYGWIN__)
and realized that splint may have not __CYGWIN__ setted...
splint +D__CYGWIN__ file.c
WORKS!
This can suggest further investigation, to find
why the missing __CYGWIN__ ?
are there other missing flags too?
# 20-may-2005:
I'm now investigatin who sets __CYGWIN__, and why splint don't have it.
--
--
I use PGP/GPG. Ask for my key if interested.
-
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -