On Thu, 2020-01-09, Mehdi Amini wrote:
> On 1/9/20 5:04 PM, David Brown wrote:
>> 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 <
ator...@gmail.com> writes:
>>>>>>
>>>>>>> On 1/6/20 7:28 PM, Ben Bacarisse wrote:
>
> [...]
>
>>
>> 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).
I think here David just commented on your example, which did not show
your original problem. It just showed you mixing clang pragmas and
the gcc compiler.
> Can I change the Makefile as I originally intended , that is , is it
> safe to change these :
>
> CC = gcc
> CCDEPMODE = depmode=gcc3
> CFLAGS = -Wall -Wno-parentheses
>
> to
>
> CC = gcc
> CCDEPMODE = depmode=gcc3
> CFLAGS =
>
> Then enable warnings on a specific part of code with what you said ? or
> even other warnings like -Wextra ?
>
> #pragma GCC diagnostic warning "-Wall"
I strongly recommend enabling maximum warnings in the Makefile (in
CFLAGS), and if it's really necessary, disabling warnings for certain
files, also in the Makefile:
my_weird_file.o: CFLAGS+=-Wno-parentheses
But I don't understand why you can't just live with the warnings, or
fix the code.
Another Make thing: CC is the standard name for the C compiler and
CFLAGS is the standard name for the C compiler options (together with
CPPFLAGS). But CCDEPMODE has, as far as I can tell, no special
meaning in Make.
Lastly, your CFLAGS should also specify what C dialect you want,
optimization and debugging options. I tend to use:
CFLAGS=-Wall -Wextra -pedantic -std=c99 -g -O2
but then I sometimes have to soften it up for individual files,
e.g. those which expect to find POSIX-specific declarations in
standard headers, or which use language extensions.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/
snipabacken.se> O o .