programmazione:cpp:appunti_cpp
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
| Entrambe le parti precedenti la revisioneRevisione precedenteProssima revisione | Revisione precedente | ||
| programmazione:cpp:appunti_cpp [29/09/2026 12:27] – Fabio Di Matteo | programmazione:cpp:appunti_cpp [01/10/2026 12:14] (versione attuale) – Fabio Di Matteo | ||
|---|---|---|---|
| Linea 118: | Linea 118: | ||
| Il mio server tcp viene eseguito su un thread esterno e il main attende 10 millisecondi finchè la porta non sia disponibile. Quando è disponibile in questo caso lancia un browser su quell' | Il mio server tcp viene eseguito su un thread esterno e il main attende 10 millisecondi finchè la porta non sia disponibile. Quando è disponibile in questo caso lancia un browser su quell' | ||
| + | |||
| + | ===== Compilare codice in base al sistema operativo ===== | ||
| + | |||
| + | Macro per Gcc . | ||
| + | |||
| + | <code c++> | ||
| + | #if defined(_WIN32) | ||
| + | |||
| + | // Windows, 32 o 64 bit | ||
| + | |||
| + | #if defined(_WIN64) | ||
| + | // Windows 64 bit | ||
| + | #else | ||
| + | // Windows 32 bit | ||
| + | #endif | ||
| + | |||
| + | #elif defined(__ANDROID__) | ||
| + | |||
| + | // Android | ||
| + | |||
| + | #elif defined(__linux__) | ||
| + | |||
| + | // Linux non Android | ||
| + | |||
| + | #elif defined(__APPLE__) && defined(__MACH__) | ||
| + | |||
| + | // macOS o altro sistema Darwin | ||
| + | |||
| + | #elif defined(__FreeBSD__) | ||
| + | |||
| + | // FreeBSD | ||
| + | |||
| + | #elif defined(__NetBSD__) | ||
| + | |||
| + | // NetBSD | ||
| + | |||
| + | #elif defined(__OpenBSD__) | ||
| + | |||
| + | // OpenBSD | ||
| + | |||
| + | #elif defined(__sun) | ||
| + | |||
| + | // Solaris / SunOS | ||
| + | |||
| + | #elif defined(_AIX) | ||
| + | |||
| + | // AIX | ||
| + | |||
| + | #elif defined(__unix__) | ||
| + | |||
| + | // Altro sistema Unix | ||
| + | |||
| + | #else | ||
| + | |||
| + | #error " | ||
| + | |||
| + | #endif | ||
| + | |||
| + | </ | ||
| + | |||
| + | ===== Una funzione per prelevare l' | ||
| + | |||
| + | Questa funzione cerca di prelevare l' | ||
| + | |||
| + | <code c++> | ||
| + | std::string get_xterminal() { | ||
| + | const char* de_env = std:: | ||
| + | | ||
| + | if (de_env != nullptr) { | ||
| + | std::string de(de_env); | ||
| + | std:: | ||
| + | |||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | |||
| + | // KDE e Plasma | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | |||
| + | // XFCE | ||
| + | if (de.find(" | ||
| + | |||
| + | // MATE | ||
| + | if (de.find(" | ||
| + | |||
| + | // LXQt / LXDE | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | |||
| + | // Elementary OS / Pantheon | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | |||
| + | // Deepin | ||
| + | if (de.find(" | ||
| + | |||
| + | // Window Managers Wayland/ | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | if (de.find(" | ||
| + | } | ||
| + | | ||
| + | | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }; | ||
| + | | ||
| + | for (const auto& term : fallback_list) { | ||
| + | std::string check_cmd = "which " + term + " > /dev/null 2>& | ||
| + | if (std:: | ||
| + | return term; | ||
| + | } | ||
| + | } | ||
| + | return " | ||
| + | } | ||
| + | </ | ||
programmazione/cpp/appunti_cpp.1790677643.txt.gz · Ultima modifica: 29/09/2026 12:27 da Fabio Di Matteo
