[PATCH] Improve portability across compilers

From: Kinkie <gkinkie_at_gmail.com>
Date: Thu, 22 Aug 2013 19:25:56 +0200

Hi,
  the attached patch improves portability across non-gcc compilers.

It addresses these issues:
- icc doesn't support #pragma interface/#pragma implementations
These are not really needed for gcc either since version 2.7,
according to GCC documentation. Removing that code will just work
(tm).

- clang is very strict on the number of parentheses in conditionals:
as a way to double-check that the programmer knows what she's doing it
will accept as valid
if (foo==bar) {} and if ((foo=bar)) {} , and emit a warning (which
then -Wall turns into an error) in case of if ((foo==bar)) {} and if
(foo=bar) {}.
This leads to bad results when the condition is a cpp macro, even
worse when the macro is defined in an external library.

- clang's static code checker complains with the idiom
if (strcmp(foo,"") != 0) {}
I've turned them into if (strlen(foo) != 0) {}

-- 
    /kinkie

Received on Thu Aug 22 2013 - 17:26:04 MDT

This archive was generated by hypermail 2.2.0 : Fri Aug 23 2013 - 12:01:12 MDT