From fd06aba05381055ab56e1ec81d56055b66462f0b Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 26 Apr 2018 15:36:13 -0700 Subject: fixes #375 integer types are error prone This change converts the various integer types like nng_socket in the public API to opaque structures that are passed by value. Basically we just wrap the integer ID. This "hack" give us strong type checks by the compiler (yay!), at the expense of not being able to directly use these as numbers (so comparisions for example don't work, and neither does initialization to zero using the normal method. Comparison of disassembly output shows that at least with the optimizer enabled there is no difference in the compiler output between using a structure or an integral value. --- docs/man/nng_dialer.5.adoc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'docs/man/nng_dialer.5.adoc') diff --git a/docs/man/nng_dialer.5.adoc b/docs/man/nng_dialer.5.adoc index daadbd0b..45c60bc9 100644 --- a/docs/man/nng_dialer.5.adoc +++ b/docs/man/nng_dialer.5.adoc @@ -16,11 +16,11 @@ nng_dialer - dialer == SYNOPSIS [source, c] ------------ +---- #include -typedef uint32_t nng_dialer; ------------ +typedef struct nng_dialer_s nng_dialer; +---- == DESCRIPTION @@ -38,6 +38,11 @@ Dialer objects are created by the or <> functions, and are always "`owned`" by a single <>. +IMPORTANT: The `nng_dialer` structure is always passed by value (both +for input parameters and return values), and should be treated opaquely. +Passing structures this way ensures gives the compiler a chance to perform +accurate type checks in functions passing values of this type. + TIP: A given <> may have multiple dialer objects, multiple <> objects, or even some of both. -- cgit v1.2.3-70-g09d2