Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros
Type Checking

Macros

#define _SOL_TYPE_CHECK(type, var, value)   ({ type var = (value); var; })
 Internal macro to check type of given value. More...
 
#define SOL_TYPE_CHECK(type, value)   _SOL_TYPE_CHECK(type, __dummy_ ## __COUNTER__, (value))
 Macro to check type of given value. More...
 
#define SSIZE_MAX   LONG_MAX
 Maximum value of a ssize variable. More...
 
#define SSIZE_MIN   LONG_MIN
 Minimum value of a ssize variable. More...
 

Detailed Description

Macro Definition Documentation

#define _SOL_TYPE_CHECK (   type,
  var,
  value 
)    ({ type var = (value); var; })

Internal macro to check type of given value.

It does so by creating a block with a new variable called var of the given type, assigning the value to it and then returning the variable.

The compiler should issue compile-time type errors if the value doesn't match the type of variable.

See Also
SOL_TYPE_CHECK()
#define SOL_TYPE_CHECK (   type,
  value 
)    _SOL_TYPE_CHECK(type, __dummy_ ## __COUNTER__, (value))

Macro to check type of given value.

The compiler should issue compile-time type errors if the value doesn't match the type.

It is often used with macros that ends into types such as 'void*' or even variable-arguments (varargs).

Example: set mystruct to hold a string, checking type:

struct mystruct {
int type;
void *value;
};
#define mystruct_set_string(st, x) \
do { \
st->type = mystruct_type_string; \
st->value = SOL_TYPE_CHECK(const char *, x); \
} while (0)

Example: a free that checks if argument is a string

#define free_str(x) free(SOL_TYPE_CHECK(char *, x))
Parameters
typethe desired type to check.
valuethe value to check, it's returned by the macro.
Returns
the given value
#define SSIZE_MAX   LONG_MAX

Maximum value of a ssize variable.

Referenced by sol_memdesc_set_as_int64(), and sol_memdesc_set_as_uint64().

#define SSIZE_MIN   LONG_MIN

Minimum value of a ssize variable.