r/cprogramming • u/Feeling-Drawer-9171 • Sep 17 '26
program wont't compile because time.h is missing even tho it's there
[CLOSED]
kind of a beginner question. i have #include <time.h> and #include <ncurses.h> in the top but it refuses to compile. im using linux with vim and gcc here's there error:
main.c:3:1: note: ‘tm’ is defined in header ‘<time.h>’; this is probably fixable by adding ‘#include <time.h>’
2 | #include <time.h>
+++ |+#include <time.h>
how can i fix it? thx for any help :)
EDIT: i fixed it and it was because i forgot to declare struct lol
15
Upvotes
8
u/Stickhtot Sep 17 '26
Did you save before compiling?
4
u/onlyonequickquestion Sep 17 '26
What is the full program /line throwing the error? Are you doing something like "tm var " instead of "struct tm var"?
3
u/PittLeElder Sep 17 '26
Also is time.h in a directory where the compiler knows to look for it?
Just because your IDE sees it does not necessarily mean the compiler has been told to include it.
2
u/Living_Beyond_6613 Sep 17 '26
If you have
tm current_time;change it tostruct tm current_time;It helps to post the entire error, command used to compile , and as much source as you can share with your questions.
2
u/cursed-stranger Sep 17 '26
Please paste whole example which doesn't compile
1
u/Dani_E2e Sep 17 '26
Ja so einen Fehler hatte ich auch mal und Stunden danach gesucht. Da gab es noch keine Foren, google...
Man darf nicht eine einzelne C Datei compilieren sondern muss das immer damals zB in einem Projekt einbinden. Heute sind das Struktur Definitionen oder make files...