Previous: Source code changes, Up: Using autosprintf in own programs [Contents]
When compiling your program with g++, use the warning option -Wall.
This is needed so that you get a compiler warning when attempting to pass
an std::string as argument.
For example, if you accidentally write
std::string s = ...;
cout << autosprintf ("Look at %s\n", s);
you want to get a compiler warning about passing an std::string through
a variadic argument list, so that you can correct your code to
std::string s = ...;
cout << autosprintf ("Look at %s\n", s.c_str ());
When linking your program, you need to link with libasprintf, because
that’s where the class is defined. In projects that use GNU autoconf,
this means adding ‘AC_LIB_LINKFLAGS([asprintf])’ to configure.in
or configure.ac, and using the @LIBASPRINTF@ Makefile variable that
it provides.