title: How to detect sem_open error in C
body: <p>when I initialize a new semaphore I would like to detect, if it was initialized properly, what´s the best way to do this?</p>
  
  <p>According to <a href="http://www.vxdev.com/docs/vx55man/vxworks/ref/semPxLib.html#sem_open" rel="nofollow">this link</a>, which says that sem_open returns -1 if error occured, I made a decision:</p>
  
  <pre><code>if ((sem_t *semaphore = sem_open("/sem1", O_CREAT | O_EXCL, 0644, 1)) == -1) {handle error}
  </code></pre>
  
  <p>But this throws warning when I try to compile - comparison between pointer and integer. Is there any way to take care of that, please?</p>
  
  <p>Thank you</p>