Next: , Previous: , Up: GNU autosprintf   [Contents]


3 Using autosprintf in own programs

To use the autosprintf class in your programs, you need to add

#include "autosprintf.h"
using gnu::autosprintf;

to your source code. The include file defines the class autosprintf, in a namespace called gnu. The ‘using’ statement makes it possible to use the class without the (otherwise natural) gnu:: prefix.

When linking your program, you need to link with libasprintf, because that’s where the class is defined. In projects using GNU autoconf, this means adding ‘AC_LIB_LINKFLAGS([asprintf])’ to configure.in or configure.ac, and using the @LIBASPRINTF@ Makefile variable that it provides.