0

For a project at university, I need to work with OpenCV. In order to do that I am learning c++ (also because I wanted to anyway). Having learned C last term, we were provided with a set of flags to increase the strictness and verbosity of the compiler. Having done some searching on what flags we can use with g++ in order to make the compiler as strict as possible, I came across this question. What I have found though is that in order to get even an empty main() to compile with the OpenCV headers without warnings I need to switch off a number of the flags including -Wall and -Wextra which were actually required on my course for C programs.

Is there any way of using the OpenCV headers but only applying the warning headers to the code that I write?

Community
  • 1
  • 1
Ben Wainwright
  • 4,224
  • 1
  • 18
  • 36
  • In GCC, you can use `-i` instead of `-I` to include headers as "system headers", and GCC won't produce warnings for those. – Kerrek SB Feb 06 '16 at 14:51
  • I am using pkg-config in my makefile though. Is there a way of getting it to output the lowercase option? – Ben Wainwright Feb 06 '16 at 14:53
  • Don't know, read the manual for pkg-config. `--variable=includedir` seems to give you the necessary ingredient. – Kerrek SB Feb 06 '16 at 14:56
  • Ok thanks. I used SED to swap the upper with lowercase, but now it can't find the header at all haha... – Ben Wainwright Feb 06 '16 at 15:02
  • @BenWainwright, Where can we find som doc reference of `-i`, I was trying to get some info on it. Interesting flag – dlmeetei Feb 06 '16 at 15:12
  • Just realised that my question is basically a duplicate of this http://stackoverflow.com/questions/1867065/how-to-suppress-gcc-warnings-from-library-headers. I changed -i to -isystem and it did the trick :) – Ben Wainwright Feb 06 '16 at 15:13
  • Oh, right, it's `-isystem`, not `-i`. Sorry. – Kerrek SB Feb 06 '16 at 15:21

0 Answers0