This is actually a reserved name. Don't use prefix underscore. Even if you know the rules (but you don't) not everybody does. So don't do it even when you do know the rules. See What are the rules about using an underscore in a C++ identifier? What are the rules about using an underscore in a C++ identifier?. In this case: Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace
This is actually a reserved name. Don't use prefix underscore. Even if you know the rules (but you don't) not everybody does. So don't do it even when you do know the rules. See What are the rules about using an underscore in a C++ identifier?. In this case: Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace
This is actually a reserved name. Don't use prefix underscore. Even if you know the rules (but you don't) not everybody does. So don't do it even when you do know the rules. See What are the rules about using an underscore in a C++ identifier?. In this case: Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace
Ok linus only is fine.
But:
#ifdef __linux__
..... Several pages of stuff.
#else
#error "OS not supported!"
#endif
Seems a good way to hide stuff.
Make it all up front.
#ifndef __linux__
#error "OS not supported!"
#endif
..... Several pages of stuff.
OK. We are good programmers and know that static storage duration objects are zero initialized. But not everybody else does.
static char init; // Default initialization of static storage duration
// is by zero initialization so this is guaranteed to be zero.
if (init) // So we know that the first time this is executed.
return; // It will fall through and run the following code.
But it would be nicer to the less experienced to make this explicit.
static char init = 0;
if (init) {
return;
}
Even so this is still is a very C way of doing stuff. A constructor would be nicer.
Prefix underscore is never a good idea.
static int _kbhit(void)
This is actually a reserved name. Don't use prefix underscore. Even if you know the rules (but you don't) not everybody does. So don't do it even when you do know the rules. See What are the rules about using an underscore in a C++ identifier?. In this case: Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace
Platform dependent code:
bool gotoxy(unsigned short x = 1, unsigned short y = 1) {
if ((x == 0) || (y == 0))
return false;
std::cout << "\x1B[" << y << ";" << x << "H";
}
There are whole libraries that hide terminal dependencies that do this more generically. Look up ncurses.
OK. Just found the.
#elif _WIN32
So you do have two implementations. In this case it is easier. to do.
// Interface declaration here.
... STUFF
#ifdef __linux__
#include "<linux File.h>"
#elif _WIN33
#include "<Windowx File.h>"
#else
#error "OS not supported!"
#endif
Static three dimensional read only list:
static std::vector<std::vector<std::vector<int>>> block_list = { /* STUFF */ };
Why not an std::array
. Or just a static const C array?