EASTL icon indicating copy to clipboard operation
EASTL copied to clipboard

printf buffer is not accumulative in android

Open mgood7123 opened this issue 3 years ago • 3 comments

the following does not work as the buffer is not accumulative

#define LOG_INFO(...) { \
    EA::StdC::Printf("INFO: " __VA_ARGS__); \
    EA::StdC::Printf("\n");        \
}

in the second, the buffer is replaced with "\0FO: " ...

mgood7123 avatar Nov 28 '21 07:11 mgood7123


#include <EAStdC/EAStdC.h>

#define LOG_INFO(...) do { \
    char logBuffer[256]; \
    EA::StdC::Snprintf(logBuffer, sizeof(logBuffer), "INFO: " __VA_ARGS__); \
    EA::StdC::Printf("%s\n", logBuffer); \
} while (0)

int main() {
    LOG_INFO("This is a log message: %d", 42);
    return 0;
}

ljluestc avatar Jan 03 '24 17:01 ljluestc

Is there a way to immediately flush the buffer after every call to the last EA::StdC::Printf?

ijacquez avatar Jan 03 '24 17:01 ijacquez

I can't find a EA StdC flush function. You can just call fflush(stdout); directly.

jhopkins-ea avatar Jan 07 '24 22:01 jhopkins-ea