0

I got the error

from error.c:31:
/usr/include/ap/mas.h:254: error: expected specifier-qualifier-list before ‘time_t’
make: *** [error.o] Error 1

Feedback

We at least need to see line 31 of error.c and line 254 of mas.h, with preferably a few lines of context around each. This error may have nothing to do with how time_t is being declared. – John Bode

Then I check in error.c (line no 31) -- #include "mas.h" then I check line no 254 in mas.h.

in mas.h

#include <sys/types.h>
typedef struct _x{
  time_t time;
}x;

Can anybody suggest where I am going wrong?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
ambika
  • 1,643
  • 5
  • 19
  • 18
  • }x; shouldn't it look like }; – jjj Feb 22 '10 at 06:09
  • @Naveen - this question is a reposting of 2295935 (which is closed as 'not a real question') with more information (as requested in comments in 2295935). – Michael Burr Feb 22 '10 at 06:21
  • @Michael: I generally prefer to see an edit of the original in those cases. @ambika: that will bump the question back to the top of the active use, and if you've done a good job, should get it reopened. – dmckee --- ex-moderator kitten Feb 22 '10 at 21:12
  • @dmckee - I wasn't aware that a closed question could be edited. Will an edited closed question generally get reconsideration? – Michael Burr Feb 22 '10 at 21:54
  • @Michael: I don't think that there is a consensus on this. Editing will bump it and get it in front of eyeballs. To actually get it reopened, he's going to have to makes his case well enough to get some action (at least a couple of reopen votes so that it shows on the 10k tools) before it falls off the front page again. When *I* take part in closing a question like that I revisit it a few times to see if the OP has edited, and cast reopen votes; to encourage good behavior. YMMV. – dmckee --- ex-moderator kitten Feb 22 '10 at 22:22

2 Answers2

6

Have you #included <time.h>?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
sth
  • 222,467
  • 53
  • 283
  • 367
  • In time.h, you can get # include /* This defines __time_t for us. */ – ambika Feb 22 '10 at 06:27
  • @ambika: If that defines `__time_t` that doesn't mean it defines `time_t` as well. The error sounds like `time_t` is not defined. Why do you want to include some internal, implementation specific header? – sth Feb 22 '10 at 06:47
  • Also: Are you sure you even include `bits/types.h`? Else it doesn't help if `time_t` is defined there. – sth Feb 22 '10 at 06:56
  • Including `` before including `"mas.h"` should do the trick, though if the OP can legitimately modify `mas.h`, it should be revised so that it can be used free-standing (it should include `` itself to ensure that it compiles correctly). – Jonathan Leffler Feb 22 '10 at 07:20
  • hi sth, thanks for your suggestion. i already include #include . then also i get error. – ambika Feb 22 '10 at 07:38
  • `sys/types.h` is not the same as `bits/types.h` - and *more importantly*, you shouldn't include `bits/types.h`. If you want to use `time_t`, you have to include `time.h`. Simple. – Alok Singhal Feb 22 '10 at 18:40
  • ambika: Just include time.h; it will include any system-specific files (bits/types.h or sys/types.h) that it needs. – John Bode Feb 22 '10 at 21:17
1

You need to include time.h before including mas.h.

qrdl
  • 34,062
  • 14
  • 56
  • 86
  • 1
    No, if mas.h needs something from time.h, then mas.h should be including time.h itself. –  Feb 24 '10 at 00:02
  • @Roger I guess you don't know how C preprocessor works. It doesn't matter if `time.h` included from `mas.h` (somewhere before the first use of `time_t` type) or before `mas.h` - it will produce the same effect. However there is a school of though (which I'm not completely support) that headers shouldn't be included from headers, but only from main source. – qrdl Feb 24 '10 at 03:02
  • 1
    Although you are correct, qrdl, that it doesn't matter how time.h is included as long as it is included, Roger is making a serious point. You should be able to include a header and have it work without any other dependencies - so it should be possible to include 'mas.h' without including anything else. And it should compile. See the NASA Goddard Space Flight Center (GSFC) coding standards for a discussion - there are numerous SO questions that cover the ground (including http://stackoverflow.com/questions/1804486/). – Jonathan Leffler Mar 11 '10 at 05:18