Normalement maintenant ça compile mieux

This commit is contained in:
Antoine Bartuccio 2018-06-06 01:15:23 +02:00
parent 6ab2711c9c
commit 0fd63b47dd
Signed by: klmp200
GPG Key ID: E7245548C53F904B
13 changed files with 84 additions and 11 deletions

8
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,8 @@
image: ubuntu:bionic
build:
stage: build
before_script:
- apt update && apt -y install make cmake gcc
script:
- mkdir cmake-build && cd cmake-build && cmake .. && make

4
Building/Building.c Normal file
View File

@ -0,0 +1,4 @@
//
// Created by Antoine Bartuccio on 05/06/2018.
//
#include "Building.h"

23
Building/Building.h Normal file
View File

@ -0,0 +1,23 @@
//
// Created by Antoine Bartuccio on 05/06/2018.
//
#ifndef LO41_BUILDING_H
#define LO41_BUILDING_H
#define ELEVATOR_NB 3
#include "../Objects.h"
#include "../List/List.h"
#include "../Elevator/Elevator.h"
#include "../CommunicationBox/CommunicationBox.h"
typedef struct o_Building {
int floors;
List * residents;
CommunicationBox * box;
Elevator elevators[ELEVATOR_NB];
} Building;
#endif //LO41_BUILDING_H

View File

@ -4,4 +4,4 @@ project(LO41 C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
add_executable(LO41 main.c List/List.h List/List.c Objects.h List/Element.c List/Element.h Objects.c)
add_executable(LO41 main.c List/List.h List/List.c Objects.h List/Element.c List/Element.h Objects.c Building/Building.c Building/Building.h Elevator/Elevator.c Elevator/Elevator.h CommunicationBox/CommunicationBox.c CommunicationBox/CommunicationBox.h)

View File

@ -0,0 +1,5 @@
//
// Created by Antoine Bartuccio on 05/06/2018.
//
#include "CommunicationBox.h"

View File

@ -0,0 +1,14 @@
//
// Created by Antoine Bartuccio on 05/06/2018.
//
#ifndef LO41_COMMUNICATIONBOX_H
#define LO41_COMMUNICATIONBOX_H
#include "../Objects.h"
typedef struct o_CommunicationBox {
} CommunicationBox;
#endif //LO41_COMMUNICATIONBOX_H

5
Elevator/Elevator.c Normal file
View File

@ -0,0 +1,5 @@
//
// Created by Antoine Bartuccio on 05/06/2018.
//
#include "Elevator.h"

14
Elevator/Elevator.h Normal file
View File

@ -0,0 +1,14 @@
//
// Created by Antoine Bartuccio on 05/06/2018.
//
#ifndef LO41_ELEVATOR_H
#define LO41_ELEVATOR_H
#include "../Objects.h"
typedef struct o_Elevator {
} Elevator;
#endif //LO41_ELEVATOR_H

View File

@ -12,7 +12,7 @@ GETTER(Element, void*, data)
SETTER(Element, Element*, previous)
SETTER(Element, Element*, next)
void $_free__Element(THIS(Element)){
void _free__Element(THIS(Element)){
List * list = this->list;
if (list != NULL) {
if (list->head == this && list->tail == this) {
@ -35,7 +35,7 @@ void $_free__Element(THIS(Element)){
free(this);
}
Element *$_init_Element(void *data, size_t size, List *list){
Element *_init_Element(void *data, size_t size, List *list){
Element *el = (Element*) malloc_or_die(sizeof(Element));
void *new_data = NULL;

View File

@ -30,6 +30,6 @@ FRIENDLY(data, List)
FRIENDLY(next, List)
FRIENDLY(previous, List)
Element *$_init_Element(void *data, size_t size, List *list);
Element *_init_Element(void *data, size_t size, List *list);
#endif //LO41_ELEMENT_H

View File

@ -54,7 +54,7 @@ void * get_tail_data_List(THIS(List)){
return NULL;
}
void $_free__List(THIS(List)){
void _free__List(THIS(List)){
this->clear(this);
free(this);
}
@ -129,7 +129,7 @@ void remove_tail_List(THIS(List)){
DELETE(this->tail);
}
List *$_init_List(){
List *_init_List(){
List *l = (List*) malloc_or_die(sizeof(List));
l->size = 0;
l->head = NULL;

View File

@ -43,6 +43,6 @@ FRIENDLY(head, Element)
FRIENDLY(tail, Element)
FRIENDLY(size, Element)
List *$_init_List();
List *_init_List();
#endif //LO41_LIST_H

View File

@ -8,9 +8,9 @@
#include <stdio.h>
#include <stdlib.h>
#define NEW(type, ...) $_init_##type(__VA_ARGS__)
#define DELETE(obj) obj->$_free_(obj)
#define DESTRUCTOR(type) void (*$_free_)(struct o_##type *this)
#define NEW(type, ...) _init_##type(__VA_ARGS__)
#define DELETE(obj) obj->_free_(obj)
#define DESTRUCTOR(type) void (*_free_)(struct o_##type *this)
#define THIS(type) type *this
#define _THIS(type) struct o_##type *this
#define CRASH(message) perror(message)
@ -35,7 +35,7 @@ void * malloc_or_die(size_t size);
#define VA_NUM_ARGS_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, N, ...) N
#define LINK_NB_(N) LINK_ALL_##N
#define LINK_NB(N) LINK_NB_(N)
#define LINK_ALL(type, obj, ...) LINK(type, obj, $_free_) LINK_NB(VA_NUM_ARGS(__VA_ARGS__))(type, obj, __VA_ARGS__)
#define LINK_ALL(type, obj, ...) LINK(type, obj, _free_) LINK_NB(VA_NUM_ARGS(__VA_ARGS__))(type, obj, __VA_ARGS__)
#define LINK_ALL_1(type, obj, method, ...) LINK(type, obj, method)
#define LINK_ALL_2(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_1(type, obj, __VA_ARGS__)
#define LINK_ALL_3(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_2(type, obj, __VA_ARGS__)