Reference Manual
for
PC-lint/FlexeLint
A Diagnostic Facility
for
C
and
C++
Software Version 8.00 and later
Document Version 8.00
July, 2001
Gimpel Software
3207 Hogarth Lane
Collegeville, PA 19426
(610) 584-4261 (voice)
(610) 584-4266 (fax)
www.gimpel.com
Copyright (c) 1985 - 2001 Gimpel Software
All Rights Reserved
No part of this publication may be reproduced, transmitted, transcribed, stored in any retrieval system, or translated into any language by any
means without the express written permission of Gimpel Software.
Disclaimer
Gimpel Software has taken due care in preparing this manual and the programs and data on the electronic disk media (if any) acco mpanying this
book including research, development and testing to ascertain their effectiveness.
Gimpel Software makes no warranties as to the contents of this manual and specifically disclaims any implied warranties of merchantability or fit-
ness for any particular purpose. Gimpel Software further reserves the right to make changes to the specifications of the progra m and contents of
the manual without obligation to notify any person or organization of such changes.
Trademarks
PC-lint and FlexeLint are trademarks of Gimpel Software. All other products and brand names used in this manual are registered trademarks or
tradenames of their respective holders.
#
1. BASIC FACTS ................................................................................................................. .........1
2. INTRODUCTION ............................................................................................................ .........2
2.1 An Example .............................................................................................................. .........2
2.2 A Lint for C++ .......................................................................................................... .........3
2.3 Language Definition ................................................................................................. .........4
3. GETTING STARTED WITH PC-LINT ........................................................................... .........6
3.1 Setup ......................................................................................................................... .........6
3.2 Configuration............................................................................................................ .........7
3.3 Running the Test Programs....................................................................................... .........8
3.4 Linting your Programs.............................................................................................. .......10
3.4.1 Other Extents for C++ Modules ....................................................................... .......11
3.4.2 Controlling the Messages................................................................................. .......11
3.4.3 Options ............................................................................................................. .......12
3.4.4 Extending the Command Line......................................................................... .......12
3.5 Integrating With Your Environment......................................................................... .......12
3.6 .dsp processing.......................................................................................................... .......13
3.7 Other Operating Systems .......................................................................................... .......15
3.7.1 Multiple Configurations ................................................................................... .......16
3.7.2 DOS-ins Files ................................................................................................... .......16
3.7.3 DOS Extender Notes........................................................................................ .......18
4. THE COMMAND LINE ................................................................................................... .......20
4.1 Indirect (.lnt) Files .................................................................................................... .......21
4.2 Exit Code.................................................................................................................. .......21
5. OPTIONS.......................................................................................................................... .......23
5.1 Rules for Specifying Options.................................................................................... .......23
5.2 Error Inhibition Options............................................................................................ .......26
5.3 Size and Alignment Options ..................................................................................... .......38
5.4 Verbosity Options ..................................................................................................... .......40
5.5 Flag Options.............................................................................................................. .......42
5.6 Message Presentation Options .................................................................................. .......59
5.6.1 Message Height Option ................................................................................... .......60
5.6.2 Message Width Option .................................................................................... .......62
5.6.3 Message Format Options ................................................................................. .......62
5.6.4 -append............................................................................................................. .......63
5.7 Other Options............................................................................................................ .......64
5.8 Compiler Adaptation................................................................................................. .......84
5.8.1 Microsoft Keywords........................................................................................ .......86
5.8.2 Compiler Codes............................................................................................... .......87
5.8.3 Customization Facilities .................................................................................. .......90
5.8.4 Identifier Characters........................................................................................ .......94
5.8.5 Preprocessor Statements.................................................................................. .......95
5.8.6 In-line assembly code ...................................................................................... .......95
5.8.7 The General Solution....................................................................................... .......96
6. LIBRARIES...................................................................................................................... .......97
6.1 Library Header Files................................................................................................. .......97
6.2 Library Modules ....................................................................................................... .....101
#
6.3 Library Object Modules ............................................................................................ .....103
6.4 Assembly Language.................................................................................................. .....104
7. LINT OBJECT MODULES .............................................................................................. .....106
7.1 What is a LOB?......................................................................................................... .....106
7.2 Why are LOB's used? ............................................................................................... .....106
7.3 Producing a LOB...................................................................................................... .....108
7.4 -lobbase to reduce lob sizes...................................................................................... .....108
7.5 Make Files................................................................................................................. .....110
7.6 Library Modules ....................................................................................................... .....111
7.7 Options for LOB's ..................................................................................................... .....112
7.8 Limitations of LOB's................................................................................................ .....112
8. STRONG TYPES ............................................................................................................. .....113
8.1 Quick Start................................................................................................................ .....113
8.2 What are Strong Types?............................................................................................ .....113
8.3 -strong....................................................................................................................... .....114
8.4 -index ........................................................................................................................ .....118
8.5 Type Hierarchies....................................................................................................... .....120
8.5.1 The Need for a Type Hierarchy ....................................................................... .....120
8.5.2 The Natural Type Hierarchy............................................................................ .....122
8.5.3 Adding to the Natural Hierarchy ..................................................................... .....123
8.5.4 Restricting Down Assignments (-father) ......................................................... .....124
8.5.5 Printing the Hierarchy Tree............................................................................. .....125
8.6 Hints on Strong Typing............................................................................................. .....126
8.7 Reference Information.............................................................................................. .....127
8.8 Strong Types and Prototypes .................................................................................... .....129
9. VALUE TRACKING ....................................................................................................... .....130
9.1 Initialization Tracking............................................................................................... .....130
9.2 Value Tracking ......................................................................................................... .....133
9.2.1 The assert remedy ............................................................................................ .....136
9.2.2 Interfunction Value Tracking........................................................................... .....137
9.2.2.1 Specific Calls - Specific Walks.............................................................. .....140
9.2.2.2 Specific Call Portrayal ............................................................................ .....141
9.2.2.3 Summary of Options.............................................................................. .....143
10. SEMANTICS.................................................................................................................. .....148
10.1 Function Mimicry (-function) ................................................................................. .....148
10.1.1 Special Functions ........................................................................................... .....148
10.1.2 Function listing .............................................................................................. .....152
10.2 Semantic Specifications.......................................................................................... .....157
10.2.1 Possible Semantics ......................................................................................... .....158
10.2.2 Semantic Expressions.................................................................................... .....161
10.2.3 Notes on Semantic Specifications.................................................................. .....166
11. OTHER FEATURES...................................................................................................... .....167
11.1 Order of Evaluation ................................................................................................ .....167
11.2 Format Checking..................................................................................................... .....168
11.3 Indentation Checking.............................................................................................. .....168
11.4 const Checking........................................................................................................ .....170
#
11.5 volatile Checking .................................................................................................... .....171
11.6 Prototype Generation.............................................................................................. .....171
11.7 Exact Parameter Matching...................................................................................... .....173
11.8 Weak Definials ....................................................................................................... .....175
11.8.1 Unused Headers............................................................................................. .....176
11.8.2 Removable from Header................................................................................ .....177
11.8.3 static-able ....................................................................................................... .....178
11.9 Unix Lint Options................................................................................................... .....178
11.10 Static Initialization................................................................................................ .....179
12. NON-ANSI EXTENSIONS ............................................................................................ .....180
12.1 Memory Models...................................................................................................... .....180
12.2 Additional Reserved Words .................................................................................... .....181
13. PREPROCESSOR .......................................................................................................... .....182
13.1 Preprocessor Symbols............................................................................................. .....182
13.2 include Processing .................................................................................................. .....182
13.2.1 INCLUDE Environment Variable................................................................. .....183
13.3 ANSI Preprocessor Facilities .................................................................................. .....184
13.3.1 #line and #...................................................................................................... .....184
13.4 Non-ANSI Preprocessing ....................................................................................... .....184
13.4.1 #assert ............................................................................................................ .....184
13.4.2 #c_include ...................................................................................................... .....185
13.4.3 #asm............................................................................................................... .....185
13.4.4 #dictionary ..................................................................................................... .....185
13.4.5 #endasm ......................................................................................................... .....185
13.4.6 #import........................................................................................................... .....186
13.4.7 #unassert ........................................................................................................ .....186
13.4.8 #include_next................................................................................................. .....186
13.5 User-Defined Keywords ......................................................................................... .....187
14. LIVING WITH LINT ...................................................................................................... .....188
14.1 An Example of a Policy.......................................................................................... .....188
14.2 Recommended Setup .............................................................................................. .....190
14.3 Using Lint Object Modules..................................................................................... .....191
14.4 Summarizing........................................................................................................... .....192
15. COMMON PROBLEMS................................................................................................ .....193
15.1 Option has no effect................................................................................................ .....193
15.2 Order of option processing ..................................................................................... .....193
15.3 Too many messages................................................................................................ .....193
15.4 What is the preprocessor doing? ............................................................................. .....194
15.5 NULL not defined................................................................................................... .....194
15.6 Error 123 using min or max.................................................................................... .....195
15.7 LONG_MIN macro................................................................................................. .....195
15.8 Plain Vanilla Functions ........................................................................................... .....195
15.9 Avoiding Lint Comments in Your Code ................................................................. .....196
15.10 Strange Compilers................................................................................................. .....196
15.11 !0 ........................................................................................................................... .....197
15.12 What Options am I using? .................................................................................... .....197
评论2
最新资源