2

I am writing a project in C using GCC 4.8 and I would like to see all the warnings (hoping to eliminate them) but the problem is I am #including some old, not maintained library which gives me huge wall of warnings in reaction to -Wall option. There is no way I fix those and I just want to ignore it focusing on code I actually write/maintain.

So can I:

gcc -Wall-excluding-OldBlackBox.c -myproject.c ?
Piotr Lopusiewicz
  • 2,514
  • 2
  • 27
  • 38
  • 1
    http://stackoverflow.com/questions/1079997/disable-specific-warnings-in-gcc – Adam Burry Sep 04 '13 at 19:30
  • @AdamBurry not ontopic, that article is about doing it through #pragmas, and here he asks for doing that through gcc parameters – pampeho Sep 04 '13 at 19:31
  • @Zupoman unfortunately I do not think the flag he wants exists. – Adam Burry Sep 04 '13 at 19:34
  • @Adam Burry - doing this by #pragmas would be good enough but I can't see an option to disable specific files (and not only kind of warnings) anywhere in answers to the thread you linked. Or maybe I can just disable all the warnings at the beginning and enable them back at the end of the blackbox.c file ? – Piotr Lopusiewicz Sep 04 '13 at 19:38
  • Are you really #including one .c file in another? That's almost never a good idea. – Nigel Harper Sep 04 '13 at 20:04
  • The project has simple enough structure (computing library I am using in other project in different language where I have actual structure) but yeah I see that this is a bad habit. – Piotr Lopusiewicz Sep 04 '13 at 20:18

2 Answers2

2

Update your makefile so that you have a different gcc -Wxxx line for different files (or groups of files)

result.exe : xxx.o yyy.o
   gcc -o result.exe xxx.o yyy.o

xxx.o : xxx.c
   gcc -Wall xxx.c

yyy.o : yyy.c
   gcc -W yyy.c
KevinDTimm
  • 14,226
  • 3
  • 42
  • 60
1

first create individual object files and then link them as single Executable.

//compilation with warnings        and   compilation without warnings  
gcc -Wall file1.c file2.c -o foo.o && gcc -w file3.c file4.c -o foo1.o 


gcc -o final foo.o foo1.o
Gangadhar
  • 10,248
  • 3
  • 31
  • 50