I am developing a C++ library for x86 or x64 Linux server programmers. The library is not open sourced and the compiled output shall be static library(.a) files.
Which build targets should I consider for most server programmers? So far, I am considering these:
- GCC and CLANG
- x86, x86_64
- debug (assert is turned on, no optimized code), release (assert is turned off) [1]
The total combination shall be 2*2*2 = 8.
Are these enough? Should I consider Ubuntu and CentOS?
[1] I have used assert() instead of run-time junction (code below) only for some performance-sensitive functions. In other cases, I use runtime junction. Runtime junction is more needed for production code, but it cause performance impact to very frequently called functions. For example, executing two junction instructions and accessing m_length takes longer time than accessing array data only.
#define runtime_assert(x); { if (g_enableAssert && !(x)) ShowError(#x); }
#ifdef _DEBUG
#define assert(x) runtime_assert(x)
#else
#define assert(x) 0
#endif
bool g_enableAssert = true;
class Array
{
int m_length;
// doing runtime junction
void Set(int index, int value)
{
runtime_assert(index>=0 && index<m_length);
...
}
// using assert
void Set(int index, int value)
{
assert(index>=0 && index<m_length);
...
}
}
Copyright Notice:Content Author:「Hyunjik Bae」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/28037263/build-targets-for-linux-static-library