简单程序出了错误,帮改改
这是个定时程序1. #include <signal.h>
2. #include <unistd.h>
3. #include <string.h>
4. #include <stdio.h>
5.
6. static char msg[] = "I received a msg.\n";
7. int len;
8. void show_msg(int signo)
9. {
10. write(STDERR_FILENO, msg, len);
11. }
12. int main()
13. {
14. struct sigaction act;
15. union sigval tsval;
16.
17. act.sa_handler = show_msg;
18. act.sa_flags = 0;
19. sigemptyset(&act.sa_mask);
20. sigaction(50, &act, NULL);
21.
22. len = strlen(msg);
23. while ( 1 )
24. {
25. sleep(2); /*睡眠2秒*/
26. /*向主进程发送信号,实际上是自己给自己发信号*/
27. sigqueue(getpid(), 50, tsval);
28. }
29. return 0;
30. }
程序在执行过程中出现错误:C(1 ):error c2059:syntax error:’constant’
C(1):error c2014:preprocessor command must start as first nonwhite space
C(2) :error c2014:preprocessor command must start as first nonwhite space
C(3):error c2014:preprocessor command must start as first nonwhite space
C(4):error c2014:preprocessor command must start as first nonwhite space
C(7):error c2059:syntax error:’constant’
C(8):error c2059:syntax error:’constant’
C(12):error c2059:syntax error:’constant’