C Collections

ccollections · Section 3

ccol_retval_to_str

ccol_retval_to_str - name of a ccol_retval code as a string

C Collections (libccollections, -lccollections)

#include <ccollections/common.h>
 
static inline const char *ccol_retval_to_str(ccol_retval r);

Returns the name of the enumerator r as a string literal, so
ccol_key_not_found gives "ccol_key_not_found". It's meant for diagnostic
messages and log records. ccollections(7) lists every code with its
value.

r  The code to name

A pointer to a string literal with static storage duration. A value that
is not an enumerator of ccol_retval gives "unknown". The function never
returns NULL.

Thread-safe. The function reads no state.

#include <stdio.h>
#include <ccollections/cthreadcomm.h>
 
int main(void) {
  ccircq *q = ccircq_create(4, NULL);
  if (!q) return 1;
  cmessage msg;
  ccol_retval rv = ccircq_try_recv(q, &msg);
  printf("%s\n", ccol_retval_to_str(rv));   /* ccol_container_empty */
  ccircq_destroy(q);
  return 0;
}

ccollections(7)