C# preprocessor differentiate between operating systems

What you are asking for is possible but needs a bit of work. Define a preprocessor variable in your csproj <PropertyGroup Condition=” ‘$(OS)’ == ‘Windows_NT’ “> <DefineConstants>_WINDOWS</DefineConstants> </PropertyGroup> Use that in your code #if _WINDOWS // your windows stuff #else // your *nix stuff #endif I find this technique useful when you have constants that … Read more

Cross-platform background service in .NET Core (think windows service/unix daemon)?

Windows service by itself is a console application which conforms to the interface rules and protocols of the Windows Service Control Manager. You can achieve the same on both platforms using .net core console application as a host.It will require to do some extra configuration to make it behave more like a real service / … Read more

How do I use CMake ExternalProject_Add or alternatives in a cross-platform way?

Problems -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} This is enough for single-configuration projects. But for Xcode and Visual Studio, you need to set CMAKE_CONFIGURATION_TYPES plus call build . –config at the build stage. See my answer. COMMAND cd <BINARY_DIR> && make install This will work only for Makefile generators of course. To be cross-platform you can use: –build . –target … Read more

What’s the simplest cross-platform way to pop up graphical dialogs in Python?

EasyGUI is a single file, and provides a simple way to work with Tkinter dialogs, but they’re still ugly non-native Tkinter dialogs. from easygui import msgbox msgbox(‘Stuff’) It can easily be installed using: $ sudo pip3 install –upgrade easygui There is a GitHub repository and documentation is very neat. Previously, there was also a fork … Read more

Macros for GCC/G++ to differentiate Linux and Mac OSX?

The next time you want to check out pre-defined macros supported by GCC on a platform, run the preprocessor with the flag -dM. It’ll list out all the predefined macros available on the system. For example: $ touch dummy.hxx $ cpp -dM ./dummy.hxx #define __DBL_MIN_EXP__ (-1021) #define __FLT_MIN__ 1.17549435e-38F #define __CHAR_BIT__ 8 #define __WCHAR_MAX__ 2147483647 … Read more

What is the NDEBUG preprocessor macro used for (on different platforms)?

The only ‘standard’ thing about NDEBUG is that it’s used to control whether the assert macro will expand into something that performs a check or not. MSVC helpfully defines this macro in release build configurations by defining it in the project for you. You can change that manually by editing the project configuration. Other toolchains … Read more

Application configuration files [closed]

YAML, for the simple reason that it makes for very readable configuration files compared to XML. XML: <user id=”babooey” on=”cpu1″> <firstname>Bob</firstname> <lastname>Abooey</lastname> <department>adv</department> <cell>555-1212</cell> <address password=”xxxx”>ahunter@example1.com</address> <address password=”xxxx”>babooey@example2.com</address> </user> YAML: babooey: computer : cpu1 firstname: Bob lastname: Abooey cell: 555-1212 addresses: – address: babooey@example1.com password: xxxx – address: babooey@example2.com password: xxxx The examples were taken … Read more