This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Specify -fno-exceptions in source file
- From: William S Fulton <wsf at fultondesigns dot co dot uk>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Sat, 18 Apr 2015 11:40:02 +0100
- Subject: Re: Specify -fno-exceptions in source file
- Authentication-results: sourceware.org; auth=none
- References: <CANGqftCVC08b4mbvff85s1w5oTLw0WUjkubo=5y5ad3T86uFdQ at mail dot gmail dot com> <CAH6eHdQ8XjhO0UkWRYBKWL=pi-dxxGE8iUgJ3=z52BbUANm8AA at mail dot gmail dot com> <CANGqftBkSMmbxyLr75Bz907dyp=WH0rVHP0cPT8ei9SO4ZAzuw at mail dot gmail dot com> <CAH6eHdQd1A6STXXQRE0_R50XdUUwWER5PZFZOsChMc3Xym6Vhg at mail dot gmail dot com>
On 16 April 2015 at 22:28, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 16 April 2015 at 19:51, William S Fulton wrote:
>> On 16 April 2015 at 10:23, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>>> On 16 April 2015 at 07:13, William S Fulton wrote:
>>>> Is it possible to specify -fno-exceptions for one translation unit?
>>>
>>> Yes.
>>>
>>>> I'd like to use -fno-exceptions for just one particular test file
>>>> without having to modify an entire build system. My attempts to use
>>>> '#pragma GCC diagnostic' didn't get anywhere.
>>>
>>> That's for controlling compiler diagnostics (errors and warnings), but
>>> -fno-exceptions is not a diagnostic option.
>>
>> Sorry, I wasn't clear enough in my original question. I wanted to
>> control this for one translation unit, but specifying it within the
>> source code and not via a command line argument to gcc.
>
> Hmm, I'm not sure if that's possible then.
>
> You could try #GCC pragma optimize "no-exceptions" but I don't think
> that flag works with the optimize pragma either (I haven't tried it
> though).
Genius, I can't see any documentation for it, but it does work for
gcc>=4.7. Thanks, it's exactly what I was looking for.
William