I have a very simple program in C with a header .h:
listas_enlazadas.c
#include <stdio.h>
#include <listas_enlazadas.h>
int longitudl(struct lista *l) {
struct lista *p;
int n;
n = 0;
p = l;
while (p != NULL) {
++n;
p = p->sig;
}
return n;
}
int main()
{
// Declaración de lista
struct lista *l;
// Inicialización de lista vacía (l=∅)
l = NULL;
longitudl(l);
return 0;
}
listas_enlazadas.h
#ifndef LISTAS_ENLAZADAS_H
#define LISTAS_ENLAZADAS_H
// Definición de nodos que conforman
// la estructura de la lista
struct nodo {
int id;
struct nodo* pSig;
};
// Lista simplemente enlazada
struct lista {
struct nodo nodos;
struct lista *sig;
};
#endif
In my IDE there are no errors marked and I can navigate between the structure without problems.
But when I try to compile with gcc, in the simplest way (gcc listas_enlazadas.c), throws me the error:
listas_enlazadas.c:2:10: error fatal: listas_enlazadas.h: No existe el fichero o el directorio
2 | #include <listas_enlazadas.h>
| ^~~~~~~~~~~~~~~~~~~~
compilación terminada.