SHARE
TWEET

Untitled

a guest May 31st, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Why does approach A work while Approach B fails? Aren't they fundamentally the same thing?
  3. Obviously something is different about them, but I guess I don't exactly know what it is.
  4.  
  5. Approach A:
  6. -----------
  7. */
  8. nanosleep((const struct timespec[]){{0, 100000000L}}, NULL);
  9.  
  10. //Works fine. No errors.
  11.  
  12.  
  13. /*
  14. Approach B:
  15. -----------
  16. */
  17. struct timespec delay_time;
  18. delay_time.tv_sec=0;
  19. delay_time.tv_nsec=100000000;
  20. nanosleep(delay_time, NULL);
  21.  
  22. /*
  23. Error message:
  24. --------------
  25. error: incompatible type for argument 1 of ‘nanosleep’
  26.    nanosleep(delay_time, NULL);
  27.  
  28. /usr/include/time.h:334:12: note: expected ‘const struct timespec *’ but argument is of type ‘struct timespec’
  29.  extern int nanosleep (const struct timespec *__requested_time,
  30. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top