From f8d9ac5d13dd37b8b57af0478e77ba1e75c813aa Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Tue, 11 May 2021 13:05:39 +0200 Subject: Adding zenservice code --- docs/cpp-coding/06-Considering_Portability.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 docs/cpp-coding/06-Considering_Portability.md (limited to 'docs/cpp-coding/06-Considering_Portability.md') diff --git a/docs/cpp-coding/06-Considering_Portability.md b/docs/cpp-coding/06-Considering_Portability.md new file mode 100644 index 000000000..5fd89ef10 --- /dev/null +++ b/docs/cpp-coding/06-Considering_Portability.md @@ -0,0 +1,21 @@ +# Considering Portability + +## Know Your Types + +Most portability issues that generate warnings are because we are not careful about our types. Standard library and arrays are indexed with `size_t`. Standard container sizes are reported in `size_t`. If you get the handling of `size_t` wrong, you can create subtle lurking 64-bit issues that arise only after you start to overflow the indexing of 32-bit integers. char vs unsigned char. + +http://www.viva64.com/en/a/0010/ + +## Use The Standard Library + +### `std::filesystem` + +C++17 added a new `filesystem` library which provides portable filesystem access across all supporting compilers + +### `std::thread` + +C++11's threading capabilities should be utilized over `pthread` or `WinThreads`. + +## Other Concerns + +Most of the other concerns in this document ultimately come back to portability issues. [Avoid statics](07-Considering_Threadability.md#statics) is particularly of note. -- cgit v1.2.3