autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Testing for GCC-like attributes and compiler switches


From: Václav Haisman
Subject: Testing for GCC-like attributes and compiler switches
Date: Fri, 15 Oct 2010 20:56:51 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4

Hi.

I am having difficulty testing for compiler features like
__declspec(dllimport) and switches like -Wall or -Werror.

The problem has started like this. I wanted to test compiler for
__declspec(dllimport) (for Windows) and if that fails for
__attribute__((visibility("default"))) (for *nix/GCC). With GCC this works
because it does support both, it supports __declspec(dllimport) even outside
Windows. But with e.g. Clang, this fails. Clang accepts the code of the
test-case with just warning like:

"conftest.cpp:20:12: warning: 'dllexport' attribute ignored"

The test-case passes but the compiler does not support the feature.

I thought I could "fix" this by trying to test for -Werror first and giving
it to the compiler for the test-case. However there is the problem with
detecting/collecting -Werror equivalent switches for all the various
compilers. Before I started with that, I have noticed the Sun Studio C++
compiler happily accepts -Wall (the test for it passes) even though it warns
that it does not know such option. So this method is useless.

How is one supposed to test these things with autoconf?

It seems to me that the only truly workable option is to fall back to
deciding the flags and features of a given compiler from combination of
platform, compiler name and compiler version. Am I right or am I missing
something, some technique or something else?

-- 
VH

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]