Preliminary test of GCC
opened this issue · comments
First of all, thanks for a good library.
I had tested this library for use on armv7m architecture but sadly the Rust friendly design breaks it since uintmx is 64 bit (unsigned long long) on 32 bit architecture. uintptr_t and size_t is always a safe bet across architectures. I'm now considering what to do, but i found a few things to share, if there are any interest in GCC support.
- Use: ´#pragma GCC diagnostic´ instead. since it works in both gcc and clang.
- No -Wno-invalid-constexpr exists in gcc. I can currently not find an alternative, it might be a problem.
- Return value in void functions? GCC don't like it.
- is_convertible has to be manually implemented. __is_convertible_to() is not available in GCC.
- make_integer_sequence needs a fix
template<typename T, T N>
using make_integer_sequence =
#if __has_builtin(__make_integer_seq)
__make_integer_seq<integer_sequence, T, N>;
#else
integer_sequence<T, __integer_pack(N)...>;
#endif
- Doxygen/ansi flags is not supported in GCC.
- -Weverything is considered a unreliable clang development only flag. See here. I recommend this instead:
set(CLANG_WARNINGS
-Wall
-Wextra # reasonable and standard
-Wshadow # warn the user if a variable declaration shadows one from a parent context
-Wnon-virtual-dtor # warn the user if a class with virtual functions has a non-virtual destructor. This helps
# catch hard to track down memory errors
-Wold-style-cast # warn for c-style casts
-Wcast-align # warn for potential performance problem casts
-Wunused # warn on anything being unused
-Woverloaded-virtual # warn if you overload (not override) a virtual function
-Wpedantic # warn if non-standard C++ is used
-Wconversion # warn on type conversions that may lose data
-Wsign-conversion # warn on sign conversions
-Wnull-dereference # warn if a null dereference is detected
-Wdouble-promotion # warn if float is implicit promoted to double
-Wformat=2 # warn on security issues around functions that format output (ie printf)
-Wimplicit-fallthrough # warn on statements that fallthrough without an explicit annotation
)
set(GCC_WARNINGS
${CLANG_WARNINGS}
-Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist
-Wduplicated-cond # warn if if / else chain has duplicated conditions
-Wduplicated-branches # warn if if / else branches have duplicated code
-Wlogical-op # warn about logical operations being used where bitwise were probably wanted
#-Wuseless-cast # warn if you perform a cast to the same type (a lot of casting to same type exists in bsl)
)