Maj du makefile (-Wall) + implémentation de init et push de la pile
This commit is contained in:
parent
1b24e9c9dc
commit
5075de4acb
2 changed files with 24 additions and 1 deletions
23
PILE/pile.c
23
PILE/pile.c
|
@ -0,0 +1,23 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "pile.h"
|
||||
|
||||
void init(struct pile ** une_pile) {
|
||||
*une_pile = (struct pile *)malloc(sizeof(struct pile));
|
||||
}
|
||||
|
||||
void push(int e, struct pile * une_pile) {
|
||||
struct cell * aux;
|
||||
if (une_pile->taille == 0) {
|
||||
une_pile->taille = 1;
|
||||
une_pile->deb = (struct cell *)malloc(sizeof(struct cell));
|
||||
une_pile->deb->suiv = NULL;
|
||||
une_pile->deb->val = e;
|
||||
} else {
|
||||
une_pile->taille += 1;
|
||||
aux = une_pile->deb;
|
||||
une_pile->deb = (struct cell *)malloc(sizeof(struct cell));
|
||||
une_pile->deb->val = e;
|
||||
une_pile->deb->suiv = aux;
|
||||
}
|
||||
}
|
2
makefile
2
makefile
|
@ -15,7 +15,7 @@ forth : forth.o PILE/pile.o LISTE/liste.o LEXER/lexer.o
|
|||
gcc -Wall LEXER/lexer.o LISTE/liste.o PILE/pile.o forth.o -o forth_interpretor
|
||||
|
||||
%.o : %.c
|
||||
gcc -c $< -o $@
|
||||
gcc -Wall -c $< -o $@
|
||||
|
||||
PILE/pile.o : PILE/pile.h
|
||||
LISTE/liste.o : LISTE/liste.h
|
||||
|
|
Loading…
Reference in a new issue