Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Why does approach A work while Approach B fails? Aren't they fundamentally the same thing?
- Obviously something is different about them, but I guess I don't exactly know what it is.
- Approach A:
- -----------
- */
- nanosleep((const struct timespec[]){{0, 100000000L}}, NULL);
- //Works fine. No errors.
- /*
- Approach B:
- -----------
- */
- struct timespec delay_time;
- delay_time.tv_sec=0;
- delay_time.tv_nsec=100000000;
- nanosleep(delay_time, NULL);
- /*
- Error message:
- --------------
- error: incompatible type for argument 1 of ‘nanosleep’
- nanosleep(delay_time, NULL);
- /usr/include/time.h:334:12: note: expected ‘const struct timespec *’ but argument is of type ‘struct timespec’
- extern int nanosleep (const struct timespec *__requested_time,
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement