Skip to content

Sample programs

franke-hub edited this page Jul 19, 2020 · 1 revision

This distribution contains sample and tutorial programs.

Library test programs

These programs also serve as library usage samples.

  • ~/src/cpp/lib/com/Test: Tests ~/src/cpp/inc/com/. includes and ~/src/cpp/lib/com/. source library.
  • ~/src/cpp/lib/gui/Test: Tests ~/src/cpp/inc/gui/. includes and ~/src/cpp/lib/gui/. source library.
  • ~/src/cpp/lib/com/Test: Tests ~/src/cpp/inc/obj/. includes and ~/src/cpp/lib/obj/. source library.
  • ~/src/cpp/lib/pub/Test: Tests ~/src/cpp/inc/pub/. includes and ~/src/cpp/lib/pub/. source library.

Stress tests

These are additional stress tests for the pub library. The source files are located in ~/src/cpp/Stress and object files in ~/obj/cpp/Stress/.

  • Common.h: Used by all stress tests
  • Alloc.cpp/Alloc.h: Stress tests ~/src/cpp/inc/pub/Allocator.h (This is basically a placeholder since the current Allocator.h uses malloc/free.)
  • Tdisp.cpp/Tdisp.h: Stress tests ~/src/cpp/inc/pub/Dispatch.h
  • Trace.cpp/Trace.h: Stress tests ~/src/cpp/inc/pub/Trace.h

Howto sample/tutorial programs

The source files are located in ~/src/cpp/Howto/.

  • Getopt.cpp: Demonstrates getopt_long usage. (Now the base source file that's copy/pasted into new code.)
  • Macros.cpp: Demonstrates how #define statements can generally be replaced by enums because GCC optimizes out unused code.
  • Process.cpp: Demonstrates how to use posix_spawn and message queues, including mq_close, mq_open, mq_getattr, mq_setattr, mq_notify, mq_send, mq_receive, mq_timedreceive, and mq_unlink. The code also describes and documents message queue usage quirks that, while documented, aren't obvious.
  • Shared_ptr.cpp: Demonstrates how to use (and not use) std::share_ptr.
  • Shm_demo.cpp: Demonstrates POSIX shared memory usage, with and without an associated memory mapped file.
  • Verify.cpp: Doesn't demonstrate anything. It just verifies expected operation sequences.