C: allergies

This commit is contained in:
2021-08-27 20:14:58 +02:00
parent 29905d7894
commit e45819d3ef
3 changed files with 9 additions and 2 deletions

View File

@@ -1,9 +1,11 @@
#include "allergies.h"
#ifdef USE_ALLERGIC_TO_FUNCTION
bool is_allergic_to(const allergen_t all, const uint32_t val)
{
return !!(val & (1 << all));
}
#endif
allergen_list_t get_allergens(uint32_t val)
{

View File

@@ -21,9 +21,13 @@ typedef struct {
bool allergens[ALLERGEN_COUNT];
} allergen_list_t;
// We could use macro...
// #define is_allergic_to(allerg, val) (!!((val) & (1 << (allerg))))
// We can choose macro or function
#ifdef USE_ALLERGIC_TO_FUNCTION
bool is_allergic_to(const allergen_t allergen, const uint32_t value);
#else
#define is_allergic_to(allerg, val) (!!((val) & (1 << (allerg))))
#endif
allergen_list_t get_allergens(uint32_t value);
/* See GNUmakefile below for explanation

View File

@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#endif
#ifdef TESTALL
#undef TEST_IGNORE
#define TEST_IGNORE() {}