[build] Revise visibility attributes usage in autotools and CMake. * CMakeLists.txt: Set `C_VISIBILITY_PRESET` to hidden for non-Windows only. Windows handles exports with `DLL_EXPORT` defined, and old MinGW toolchains emit a lot of warnings about visibility attributes not being supported in this configuration. * build/unix/configure.raw: Revise visibility attributes checks by compiling a better test program with `-Werror` in `CFLAGS` so that warnings correctly indicate unsupported configurations.