Why do I have a compilation issues with time.h ?
8 次查看(过去 30 天)
显示 更早的评论
When working with the header file time.h, I receive the following error if I use the structure timespec even if the list of header files is correct:
<file.c>: undefined size for `incomplete struct timespec defined at <file.c>:<line> timeout'
If I use the struct itimerspec, I receive the following error:
Verifying test2.c
<file.c>, line 6: error: incomplete type is not allowed
Line 6 is the line where itimerspec is used.
采纳的回答
MathWorks Support Team
2009-9-28
1. As one can see in the comment of the structure timespec in time.h, this structure is a POSIX structure.
The POSIX extension will be taken into account if you define the flag _GNU_SOURCE (see features.h)
2. For itimerspec, this structure is declared in
#include <linux/time.h>
Note that linux/time.h is not an Ansi include. And it actually contains non Ansi keywords, like '__signed__'.
So the compilation issue can be fixed by providing an include file that contains the following:
#define _GNU_SOURCE 1
#define __signed__
#include <linux/time.h>
This include file should be used with the option '-include'.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Portfolio Optimization and Asset Allocation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!