Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #148878

Re: Warning in LLVM Clang

From David Brown <david.brown@hesbynett.no>
Newsgroups comp.lang.c
Subject Re: Warning in LLVM Clang
Date 2020-01-09 14:34 +0100
Organization A noiseless patient Spider
Message-ID <qv7a56$kbk$1@dont-email.me> (permalink)
References (2 earlier) <qv1s14$pi0$1@dont-email.me> <87zhezjpzn.fsf@bsb.me.uk> <qv4k2e$ubn$1@dont-email.me> <qv4nui$k6m$1@dont-email.me> <qv779f$48g$1@dont-email.me>

Show all headers | View raw


On 09/01/2020 13:45, Mehdi Amini wrote:
> On 1/8/20 5:41 PM, David Brown wrote:
>> On 08/01/2020 14:05, Mehdi Amini wrote:
>>> On 1/7/20 6:03 PM, Ben Bacarisse wrote:
>>>> Mehdi Amini <atorrses@gmail.com> writes:
>>>>
>>>>> On 1/6/20 7:28 PM, Ben Bacarisse wrote:
>>>
> 
> [...]
> 
>> It does not matter how big the source is.  What you have to do is figure
>> out a minimal, stand-alone, compilable snippet of code that demonstrates
>> the problem.  It does not have to be an extraction from the original
>> code - usually it is better to write a new test "foo" function that has
>> the same effect.  This process has at least three major benefits:
>>
>> 1. It means other people can help you, because they can see a short bit
>> of code.  No one is going to wade through dozens of long source files on
>> github (or whatever) to help, but many are happy to read through a dozen
>> lines of code in a Usenet post.
>>
>> 2. During the process of making such a sample, there is a good chance
>> that you will figure it out yourself, and learn something in the
>> process.  This happens often.
>>
>> 3. You can paste the code into <https://godbolt.org> and test it out
>> with different compilers, different versions, different warning settings
>> and flag options.  This can be a big help for you in finding out what is
>> going on.
>>
>>
>>
>>> On compiler versions:
>>>
>>> :~$ clang --version
>>> clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
>>> Target: x86_64-pc-linux-gnu
>>> Thread model: posix
>>> InstalledDir: /usr/bin
>>>
>>> :~$ gcc --version
>>> gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
>>> Copyright (C) 2017 Free Software Foundation, Inc.
>>> This is free software; see the source for copying conditions.  There is
>>> NO
>>> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
>>> PURPOSE.
>>>
> 
> OK , here is my try on this link:
> 
> https://www.tutorialspoint.com/compile_c_online.php
> 
> Code:
> // pragma problem
> #include <stdlib.h>
> 
> #pragma clang diagnostic push
> #pragma clang diagnostic warning "-Wall" // -Weverything
> int main(void)
> {
>     //exit(1);
>     return 0;
> }
> #pragma clang diagnostic pop
> 
> Result:
> $gcc -o main *.c -Wall -Wno-parentheses
> main.c:4:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
>  #pragma clang diagnostic push
> 
> main.c:5:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
>  #pragma clang diagnostic warning "-Wall" // -Weverything
> 
> main.c:11:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
>  #pragma clang diagnostic pop
> 
> $main
> 
> 

You are using clang-specific pragmas, then compiling with gcc with the
warning for unknown pragmas enabled.  The compiler is giving you the
warning you asked for.

Your choices include:

1. Disable the "unknown pragma" warning (gcc -Wall -Wno-unknown-pragmas).

2. Compile with clang.

3. Change the clang-specific pragmas to gcc-specific equivalents:

	#pragma GCC diagnostic warning "-Wall"

(clang might happily accept that too - it accepts a fair number of
gcc-specific extensions.)

4. Use conditional compilation testing compiler type, and give
appropriate pragmas for different compilers.

5. Drop the pragma entirely, and put the flags in the builder (makefile,
cmake, or whatever).

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-06 17:57 +0330
  Warning in LLVM Clang chad <cdalten@gmail.com> - 2020-01-06 07:47 -0800
  Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-06 15:58 +0000
    Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-07 15:32 +0330
      Which compiler is it, anyway??? (Was: Warning in LLVM Clang) gazelle@shell.xmission.com (Kenny McCormack) - 2020-01-07 12:58 +0000
      Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-07 14:33 +0000
        Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-08 16:35 +0330
          Re: Warning in LLVM Clang David Brown <david.brown@hesbynett.no> - 2020-01-08 15:11 +0100
            Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-09 16:15 +0330
              Re: Warning in LLVM Clang David Brown <david.brown@hesbynett.no> - 2020-01-09 14:34 +0100
                Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-09 17:49 +0330
                Re: Warning in LLVM Clang Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-09 19:35 +0000
                Re: Warning in LLVM Clang David Brown <david.brown@hesbynett.no> - 2020-01-10 10:28 +0100
                Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-10 12:39 +0000
                Re: Warning in LLVM Clang Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-10 12:57 +0000
                Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-10 13:23 +0000
                Re: Warning in LLVM Clang David Brown <david.brown@hesbynett.no> - 2020-01-10 14:09 +0100
                Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-10 16:45 +0330
                Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-10 13:20 +0000
                Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-10 17:20 +0330
                Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-10 17:24 +0330
                Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-10 23:52 +0000
                Re: Warning in LLVM Clang scott@slp53.sl.home (Scott Lurndal) - 2020-01-10 15:29 +0000
                Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-10 23:28 +0000
                Re: Warning in LLVM Clang Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-11 14:21 +0000
              Re: Warning in LLVM Clang James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-09 22:08 -0500
                Not exactly an "alias", but that's just being a CLC pedant... (Was: Warning in LLVM Clang) gazelle@shell.xmission.com (Kenny McCormack) - 2020-01-10 09:52 +0000
                Re: Not exactly an "alias", but that's just being a CLC pedant... (Was: Warning in LLVM Clang) David Brown <david.brown@hesbynett.no> - 2020-01-10 11:26 +0100
                Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-10 16:48 +0330
                Re: Warning in LLVM Clang Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-10 09:34 -0800
                Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-11 14:41 +0330
  Re: Warning in LLVM Clang Guillaume <message@bottle.org> - 2020-01-06 17:23 +0100
    Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-07 15:39 +0330

csiph-web