Hi. Thanks for reply. I've tested print with '\n' and it works in chrome as expected (emscripten 1.25). But it does not work in safari (I can't see print before input dialog shown) 31 Окт 2014 г. 22:37 пользователь "Alecazam" <a...@figma.com> написал:
Hey Anton, You should know that fflush(stdout) was implemented in a patch to the code recently. It was a no-op before. You might just need to sync to that. /n should definitely not lead to an automatic fflush. That's not the way printf functions, which is supposed to buffer output. I never use cout. cout is the worst api for atomicity and brevity of formatting. On Monday, October 27, 2014 12:27:45 PM UTC-7, Alon Zakai wrote: > It might be that safari buffers the event to render the query, but > immediately executes a prompt() call. I'm not sure if that would be a bug > or not. You might need to just do it asynchronously, using > emscripten_call_async etc. > > - Alon > > > On Sun, Oct 26, 2014 at 3:49 AM, Anton Smirnov <d...@antonsmirnov.name> > wrote: > >> Few topics ago i've asked similar question >> <https://groups.google.com/forum/#!topic/emscripten-discuss/ilSnBNrd2kY> >> and i was answered that printf needs '\n' or fflush() to force output. That >> works great in Google chrome but unfortunately does not work in Safari >> (which is default browser and widely used on mac). How can i force output >> or workaround it (i agree it can be Safari's bug/feature though)? >> >> Full story: >> >> #include <iostream> >> >> >> using namespace std; >> >> >> int main() { >> char name[128]; >> cout << "type your name:\n"; >> cin.getline(name, sizeof(name)); >> cout << "hi, " << name << endl; >> >> >> return 0; >> } >> >> >> In Safari input box is shown before "type your name" is printed: >> >> >> <https://lh5.googleusercontent.com/-KT3eWAPE1ZE/VEzRNE6E86I/AAAAAAAABAA/qaBhNWD33jA/s1600/%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%2B%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%2B2014-10-26%2B%D0%B2%2B16.43.18.png> >> >> I've try fflush(stdout) too, but unfortunately it does not help. >> >> After text input done cout works as expected: >> >> type your name: *(input dialog shown and 'Anton' is typed)* >> >> hi, Anton >> >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "emscripten-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to emscripten-discuss+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/5EN4FxJwYUU/unsubscribe . To unsubscribe from this group and all its topics, send an email to emscripten-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.