Skip to content

Commit

Permalink
Refs #11400. Use variatic template in place of variatic macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumsteve committed Mar 19, 2015
1 parent 77f0d75 commit 00badb0
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions Code/Mantid/Framework/DataHandling/src/SaveSPE.cpp
Expand Up @@ -25,21 +25,22 @@ DECLARE_ALGORITHM(SaveSPE)
* @throws std::runtime_error :: throws when there is a problem writing to disk,
* usually disk space or permissions based
*/

#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#endif

#define FPRINTF_WITH_EXCEPTION(stream, format, ...) \
if (fprintf(stream, format, ##__VA_ARGS__) <= 0) { \
throw std::runtime_error( \
"Error writing to file. Check folder permissions and disk space."); \

namespace {

template <typename... vargs>
void FPRINTF_WITH_EXCEPTION(FILE *stream, const char *format, vargs... args) {
if (fprintf(stream, format, args...) <= 0) {
throw std::runtime_error(
"Error writing to file. Check folder permissions and disk space.");
}

#if __clang__
#pragma clang diagnostic pop
#endif
}

// special case needed for case with only two arguments.
void FPRINTF_WITH_EXCEPTION(FILE *stream, const char *format) {
FPRINTF_WITH_EXCEPTION(stream, format, "");
}
}

using namespace Kernel;
using namespace API;
Expand Down

0 comments on commit 00badb0

Please sign in to comment.