https://hal.archives-ouvertes.fr/hal-03445821
boxed.h
/*
Copyright Universite de Versailles Saint-Quentin en Yvelines 2009
AUTHORS: Sebastien Briais, Sid Touati
This file is part of GDD.
GDD is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
GDD is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with GDD. If not, see
<http://www.gnu.org/licenses/>.
*/
#ifndef __BOXED_H
#define __BOXED_H
/** \internal
\file boxed.h
\brief Syntactic sugar to easily handle boxed values (int, double, ...) */
#include "util.h"
/* boxed(t) is the type of boxed value of type t */
#define boxed(type$) type$ *
/* create a boxed value of type t with initial value v */
#define boxed_create(type$, v$) \
({ boxed(type$) _x = safe_malloc(sizeof(type$)); \
*_x = (v$); \
_x; })
/* free boxed data */
#define boxed_delete free
/* set value of boxed value */
#define boxed_set(x$, v$) (*(x$))=(v$)
/* get value of boxed value */
#define boxed_get(x$) (*(x$))
#endif