mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-06-11 20:53:24 +08:00
Convert tprintf() to C++ style without va args and attributes.
This commit is contained in:
parent
3299901b9c
commit
8cb04183c1
@ -70,15 +70,6 @@ FILE *get_debugfp() {
|
|||||||
return debugfp;
|
return debugfp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trace printf.
|
|
||||||
void tprintf(const char *format, ...) {
|
|
||||||
FILE *f = get_debugfp();
|
|
||||||
va_list args; // variable args
|
|
||||||
va_start(args, format); // variable list
|
|
||||||
vfprintf(f, format, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
TessErrStream tesserr;
|
TessErrStream tesserr;
|
||||||
|
|
||||||
} // namespace tesseract
|
} // namespace tesseract
|
||||||
|
@ -21,26 +21,22 @@
|
|||||||
|
|
||||||
#include "params.h" // for INT_VAR_H
|
#include "params.h" // for INT_VAR_H
|
||||||
#include <tesseract/export.h> // for TESS_API
|
#include <tesseract/export.h> // for TESS_API
|
||||||
|
#include <utility> // for std::forward
|
||||||
|
|
||||||
namespace tesseract {
|
namespace tesseract {
|
||||||
|
|
||||||
#if !defined(__GNUC__) && !defined(__attribute__)
|
|
||||||
# define __attribute__(attr) // compiler without support for __attribute__
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Disable some log messages by setting log_level > 0.
|
// Disable some log messages by setting log_level > 0.
|
||||||
extern TESS_API INT_VAR_H(log_level);
|
extern TESS_API INT_VAR_H(log_level);
|
||||||
|
|
||||||
// Main logging function.
|
|
||||||
extern TESS_API void tprintf( // Trace printf
|
|
||||||
const char *format, ...) // Message
|
|
||||||
__attribute__((format(printf, 1, 2)));
|
|
||||||
|
|
||||||
// Get file for debug output.
|
// Get file for debug output.
|
||||||
FILE *get_debugfp();
|
TESS_API FILE *get_debugfp();
|
||||||
|
|
||||||
|
// Main logging function. Trace printf.
|
||||||
|
template <typename ... Types>
|
||||||
|
auto tprintf(Types && ... args) {
|
||||||
|
return fprintf(get_debugfp(), std::forward<Types>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace tesseract
|
} // namespace tesseract
|
||||||
|
|
||||||
#undef __attribute__
|
|
||||||
|
|
||||||
#endif // define TESSERACT_CCUTIL_TPRINTF_H
|
#endif // define TESSERACT_CCUTIL_TPRINTF_H
|
||||||
|
Loading…
Reference in New Issue
Block a user