If BAD_EOF was a macro, you could stringize it:
#define STRINGIZE_DETAIL_(v) #v #define STRINGIZE(v) STRINGIZE_DETAIL_(v) "My error code is #" STRINGIZE(BAD_EOF) "!" But it's not (and that's just about always a good thing), so you need to formatformat the string:
stringf("My error code is #%d!", BAD_EOF) stringstream ss; ss << "My error code is #" << BAD_EOF << "!"; ss.str() If this was a huge concern for you (it shouldn't be, definitely not at first), use a separate, specialized string for each constant:
unsigned const BAD_EOF = 1; #define BAD_EOF_STR "1" This has all the drawbacks of a macro plus more to screwup maintain for a tiny bit of performance that likely won't matter for most apps. However, if you decide on this trade-off, it has to be a macro because the preprocessor can't access values, even if they're const.