当前位置: 代码迷 >> C语言 >> 简单程序出了错误,帮改改
  详细解决方案

简单程序出了错误,帮改改

热度:397   发布时间:2008-05-27 10:10:31.0
简单程序出了错误,帮改改
这是个定时程序
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’
搜索更多相关的解决方案: 改改  

----------------解决方案--------------------------------------------------------
晕,都是些什么东西!
根本就不对!
----------------解决方案--------------------------------------------------------
  相关解决方案