Constants not loaded by compiler

后端 未结 5 1386
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-04 19:49

I started studying POSIX timers, so I started also doing some exercises, but I immediately had some problems with the compiler. When compiling this code, I get some strange

5条回答
  •  半阙折子戏
    2021-01-04 20:32

    Firstly, you can compile your code with -std=gnu99 instead of -std=c99 if you want to have the identifiers SIGEV_SIGNAL, sigeventStruct, and CLOCK_MONOTONIC available.

    As noted by @adwoodland these identifiers are declared when _POSIX_C_SOURCE is set to a value >= 199309L, which is the case with -std=gnu99. You can also use -D_POSIX_C_SOURCE=199309L -std=c99 or have the macro defined in source code.

    Secondly, see the timer_create prototype, you have to pass pointers as the second and the third argument to the function:

    timer_create(CLOCK_MONOTONIC, &sigeventStruct, &numero1)
                                  ^                ^
    

    Also you have to include the standard header string.h for strerror function declaration.

提交回复
热议问题