Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: [OMPI devel] snprintf vs. sprintf
From: Brad Penoff (penoff_at_[hidden])
Date: 2008-10-27 08:08:05


In the current ompi-trunk (r19808), my build was breaking. I have
created a small patch to fix this, but I wanted to ask the team about
something first. One of the problems was with snprintf. I read a
little bit more about this and I found this quote about snprintf:

"snprintf does not form part of the widely implemented ANSI C
standard, as sprintf does. However, it came into the language for the
later C99 standard and often existed in C libraries before that."

So I'm wondering, should the use of snprintf as in
ompi/contrib/vt/vt/tools/opari/tool/ depend on the value of

For my system, one "fix" seemed to be to just delete this "using
std::snprintf;" line. Everything then compiled and worked, but I don't
know how general/desired this "solution" is. Any comments on snprintf
and this solution?


$ svn diff
Index: ompi/contrib/vt/vt/tools/opari/tool/
--- ompi/contrib/vt/vt/tools/opari/tool/ (revision 19808)
+++ ompi/contrib/vt/vt/tools/opari/tool/ (working copy)
@@ -15,7 +15,6 @@
   using std::cout;
   using std::cerr;
 #include <cstdio>
- using std::snprintf;
   using std::remove;
 #include <cstring>
   using std::strcmp;
Index: orte/tools/orte-iof/orte-iof.c
--- orte/tools/orte-iof/orte-iof.c (revision 19808)
+++ orte/tools/orte-iof/orte-iof.c (working copy)
@@ -37,6 +37,9 @@
 #include <stdlib.h>
 #endif /* HAVE_STDLIB_H */
+#include <signal.h>
+#endif /* HAVE_SIGNAL_H */
 #include <sys/stat.h>
 #endif /* HAVE_SYS_STAT_H */