Reputation: 85
Using gcc, I get these errors when compiling something that makes use of ucontext.h
/usr/include/sys/ucontext.h: At top level:
/usr/include/sys/ucontext.h:138: error: expected identifier or ‘(’ before numeric constant
/usr/include/sys/ucontext.h:139: error: expected ‘;’ before ‘stack_t’
Looking at ucontext.h, this is what seems to cause:
134 /* Userlevel context. */
135 typedef struct ucontext
136 {
137 unsigned long int uc_flags;
138 struct ucontext *uc_link;
139 stack_t uc_stack;
140 mcontext_t uc_mcontext;
141 __sigset_t uc_sigmask;
142 struct _libc_fpstate __fpregs_mem;
143 } ucontext_t;
How could line 138 and 139 raise these errors? Don't know what to do since this is a standard sys header.
Upvotes: 2
Views: 2130
Reputation: 1286
This problem is probably caused by #define
somewhere in the code, which defines uc_link as some integer.
Example:
#define uc_link 22
The most efficient way to find it in Unix/Linux would be to run grep -r "uc_link" .
on your source code directory.
If you use git to manage your source code you can do git grep "uc_link"
instead.
If this define is present in one file and you use ucontext.h in it, then you should try to decouple your ucontext logic from the logic which demands this #define
.
Also, I must note that it is a bad practice to have #define
s which are not ALL_CAPS. One of the reasons is well represented by the problem you encountered, another reason is the fact that everyone expects them to be ALL_CAPS and your code becomes less intelligible and less readable to other programmers who may want to collaborate with you.
Upvotes: 3