Zeex / sampgdk

Write SA-MP gamemodes in C/C++
http://zeex.github.io/sampgdk
Apache License 2.0
156 stars 83 forks source link

Trouble with std::cout and ENDL #203

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hello This is not a critical issue, but it made me spend a few hours.

Code:

PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit() {
  std::cout << "GAME MODE INIT";
  return true;
}

Trouble: The message "GAME MODE INIT" will appear only when the server is turned off But, if I add "endl" or "\n", then the message is output correctly (when this callback is called)

I use:

  1. docker image i386:ubuntu:18.04 (for compile)
  2. gdk 4.6.2 amalgamation

What could be the problem?

Zeex commented 5 years ago

That's just how stdout works, it buffers content until your print a newline or flush it. It's a general C/C++ thing, not related to sampgdk.

You could also use logprintf (or sampgdk::logprintf).