PCLint 帮助中关于如何获得gcc/g++编译宏定义和头文件搜索目录的方法说明

/* co-gcc.lnt: This is the seed file for configuring Lint for use with
GCC versions 2.95.3 and later.

Like all compiler options files this file is intended to be used
as follows:

lint co-gcc.lnt source-files-to-be-linted

Some of the information that co-gcc.lnt requires needs to be
furnished with the help of the gcc system itself.

If any of these directions are unclear, you may gain a better insight
into what is happening by checking the file gcc-readme.txt

For C, first create an empty file named empty.c and then
run the command (options are case sensitive):

gcc -E -dM empty.c >lint_cmac.h

This will capture macro definitions in a file that will be included
automatically at the beginning of each module by use of the -header
option within co-gcc.lnt. The macros may change as you change
compiler options so that ultimately you may want to incorporate
this step into a make facility.

Next we need to determine the search directories. If you run

gcc -c -v empty.c

you will see among other things this coveted list. For example you
might get:

...
#include "..." search starts here
#include <...> search starts here
/usr/local/include
/usr/lib/gcc/i686-apple-darwin8/4.0.1/include
/usr/include
/System/Library/Frameworks
/Library/Frameworks
End of search list.
...

For each directory shown (there are five in the list above) prefix
the directory name by a "--i" and place it in a file whose name is,
say, include.lnt. You may then begin linting programs by using the
command

lint co-gcc.lnt include.lnt source-files

Note: it is conventional to place both .lnt files into a single .lnt
file called std.lnt

For C++, run the command (options are again case sensitive):

g++ -E -dM empty.c >lint_cppmac.h

This will capture C++ macro definitions in a file that will be
included automatically at the beginning of each C++ module
at the request of co-gcc.lnt.

Next we need to determine C++ search directories. If you run

g++ -c -v empty.c

As in the case of C you should prepend a --i onto each directory
displayed and place these options into a file such as include.lnt.
Again, there is nothing sacred about the name and if you intend to
do mixed C and C++ programming it will be necessary for you to use
a differently named file. The rest proceeds as before.

Note, some options in this file (such as the size options, i.e. -sp4
indicating that pointers are four bytes wide) may need to be changed.
See "System Dependent Options" below.
*/

你可能感兴趣的:(gcc)