Note that there are some explanatory texts on larger screens.

plurals
  1. POConstants not loaded by compiler
    primarykey
    data
    text
    <p>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 messages about macros like CLOCK_MONOTONIC. Those are defined in various libraries like time.h etc. but the compiler gives me errors as if they are not defined.</p> <p>It is strange because I am using a Fedora 16, and some of my friends with Ubuntu get less compiler errors than I :-O</p> <p>I am compiling with <code>gcc -O0 -g3 -Wall -c -fmessage-length=0 -std=c99 -lrt</code></p> <p>Here the errors I get:</p> <ul> <li><p><code>struct sigevent sigeventStruct</code> <strong>gives</strong>:</p> <pre><code>storage size of ‘sigeventStruct’ isn’t known unused variable ‘sigeventStruct’ [-Wunused-variable] Type 'sigevent' could not be resolved unknown type name ‘sigevent’ </code></pre></li> <li><p><code>sigeventStruct.sigev_notify = SIGEV_SIGNAL</code> <strong>gives</strong>:</p> <pre><code>‘SIGEV_SIGNAL’ undeclared (first use in this function) request for member ‘sigev_notify’ in something not a structure or union Field 'sigev_notify' could not be resolved </code></pre></li> <li><p><code>if(timer_create(CLOCK_MONOTONIC, sigeventStruct, numero1) == -1)</code> <strong>gives</strong>:</p> <pre><code>implicit declaration of function ‘timer_create’ [-Wimplicit-function- declaration] ‘CLOCK_MONOTONIC’ undeclared (first use in this function) Symbol 'CLOCK_MONOTONIC' could not be resolved </code></pre></li> </ul> <p>Here is the code:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;fcntl.h&gt; #include &lt;time.h&gt; #include &lt;stdlib.h&gt; #include &lt;errno.h&gt; #include &lt;unistd.h&gt; #include &lt;signal.h&gt; int main() { timer_t numero1; struct sigevent sigeventStruct; sigeventStruct.sigev_notify = SIGEV_SIGNAL; if(timer_create(CLOCK_MONOTONIC, sigeventStruct, numero1) == -1) { printf( "Errore: %s\n", strerror( errno ) ); } return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload