NASD Programmer's Documentation
Printing output

Many components of the NASD tree will wish, at times, to output data, as with printf(). This need is not limited to various front-end programs for NASD functionality, although it is most obvious there. Many programmers find it useful to add diagnostic output to their code, either to indicate the nature of an unexpectedly irrecoverable error, or to debug work in progress. For that reason, NASD provides macro definitions for some format strings and "preferred" formatting for other types. These are enumerated in the table below. Note that some of these types will be described in later portions of this document.

Type nameDescriptionOutput format
nasd_byteOne byte"0x%02x"
nasd_int8An eight-bit signed integer"0x%02x"
nasd_uint8An eight-bit unsigned integer"0x%02x"
nasd_int16A sixteen-bit signed integer"%hd"
nasd_uint16A sixteen-bit unsigned integer"%hu"
nasd_int32A thirty-two-bit signed integer"%d"
nasd_uint32A thirty-two-bit unsigned integer"%u"
nasd_int64A sixty-four-bit signed integer, printed base 10"%" NASD_64s_FMT
nasd_uint64A sixty-four-bit unsigned integer, printed base 10"%" NASD_64u_FMT
nasd_int64A sixty-four-bit signed integer, printed base 16"0x%" NASD_64x_FMT
nasd_uint64A sixty-four-bit unsigned integer, printed base 16"0x%" NASD_64x_FMT
nasd_thread_id_tA thread identifier"%" NASD_THREAD_ID_FMT
nasd_identifier_tA NASD object identifier"0x%" NASD_ID_FMT

Examples

Printing some integers

{
  nasd_uint16 val16;
  nasd_uint32 val32;
  nasd_uint64 val64;

  /* ... */

  printf("val16 is %hu (0x%hx)\n", val16, val16);
  printf("val32 is %u (0x%x)\n", val32, val32);
  printf("val64 is %" NASD_64u_FMT " (0x%" NASD_64x_FMT ")\n", val64, val64);

}

Printing a NASD identifier

{
  nasd_identifier_t nasdid;

  /* ... */

  printf("NASD id 0x%" NASD_ID_FMT "\n", nasdid);

}

Printing a thread identifier

{
  nasd_thread_id_t thread_id;

  thread_id = nasd_thread_self();
  printf("This thread is %" NASD_THREAD_ID_FMT "\n", thread_id);

}


<--- ---> ^<br>|<br>|
Basic types Results and errors NASD Programmer's Documentation