Reference Manual
for
PC-lint/FlexeLint
A Diagnostic Facility
for
CandC++
Software Version 9.00 and Later
Document Version 9.00
September, 2008
Gimpel Software
3207 Hogarth Lane
Collegeville, PA 19426
(610)584-4261 (Voice)
(610)584-4266 (fax)
www.gimpel.com
Coypright (c) 1985 - 2008 Gimpel Software
All Rights Reseved
No part of this publication may be reproduced, transmitted, transcribed, stored in any retrieval sys-
tem, 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) accompanying 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 fitness for any particular purpose. Gimpel Software
further reserves the right to make changes to the specifications of the program 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.
I
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 ................................................................................................... 11
3.4.1 Other File Extensions for C++ Modules ............................................................... 11
3.4.2 Controlling the Messages ...................................................................................... 12
3.4.3 Options .................................................................................................................. 12
3.4.4 Extending the Command Line .............................................................................. 12
3.5 Integrating With Your Environment .............................................................................. 13
3.6 Project Files ................................................................................................................... 14
3.7 DOS and OS/2 ............................................................................................................... 14
3.7.1 Multiple Configurations ........................................................................................ 15
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.2.1 Meta Characters for -esym, -efile, -emacro, -efunc, -estring, -etype, -ecall .......... 42
5.3 Size and Alignment Options .......................................................................................... 46
5.4 Verbosity Options .......................................................................................................... 49
5.5 Flag Options ................................................................................................................... 51
5.6 Message Presentation Options ........................................................................................ 80
5.6.1 Message Height Option ........................................................................................ 80
5.6.2 Message Width Option ......................................................................................... 83
5.6.3 Message Format Options ...................................................................................... 83
5.6.4 Appending Text to Messages ................................................................................ 86
5.7 Other Options .................................................................................................................87
5.8 Compiler Adaptation .................................................................................................... 121
5.8.1 Microsoft Keywords ........................................................................................... 123
5.8.2 Compiler Codes .................................................................................................. 124
5.8.3 Customization Facilities ..................................................................................... 128
5.8.4 Identifier Characters ........................................................................................... 137
5.8.5 Preprocessor Statements ..................................................................................... 137
5.8.6 In-line assembly code ......................................................................................... 137
5.8.7 Pragmas ................................................................................................................ 138
5.8.8 The General Solution .......................................................................................... 143
II
5.9 Self-Referencing Options Files .................................................................................... 144
6. LIBRARIES ......................................................................................................................... 147
6.1 Library Header Files .................................................................................................... 147
6.2 Library Modules .......................................................................................................... 151
6.3 Library Object Modules ............................................................................................... 152
6.4 Assembly Language Modules ...................................................................................... 153
7. FAST HEADER PROCESSING .......................................................................................... 155
7.1 Pre-compiled Headers ................................................................................................... 155
7.1.1 Introduction to pre-compiled headers .................................................................. 155
7.1.2 Designating the pre-compiled header .................................................................. 155
7.1.3 Monitoring pre-compiled headers ........................................................................ 156
7.1.4 The use of make files ........................................................................................... 156
7.2 Bypass Headers ............................................................................................................. 157
7.2.1 Constraints on Bypass Headers ............................................................................ 160
8. LINT OBJECT MODULES ................................................................................................. 163
8.1 What is a LOB? ............................................................................................................ 163
8.2 Why are LOB's used? .................................................................................................. 163
8.3 Producing a LOB ......................................................................................................... 165
8.4 -lobbase to reduce lob sizes ......................................................................................... 165
8.5 Make Files .................................................................................................................... 167
8.6 Library Modules .......................................................................................................... 168
8.7 Options for LOB's ........................................................................................................ 169
8.8 Limitations of LOB's ................................................................................................... 169
9. STRONG TYPES ................................................................................................................ 170
9.1 Quick Start ................................................................................................................... 170
9.2 What are Strong Types? ............................................................................................... 170
9.3 -strong .......................................................................................................................... 171
9.4 Multiplication and Division of Strong Types ............................................................... 175
9.4.1 Dimension (Jd) ..................................................................................................... 176
9.4.2 Dimensionally Neutral (Jn) ................................................................................. 176
9.4.3 Anti-Dimensional (Ja) ......................................................................................... 177
9.4.4 Dimensional Analysis .......................................................................................... 177
9.4.5 Conversions ......................................................................................................... 179
9.4.6 Integers ................................................................................................................. 180
9.4.7 Migrating to Dimensions ..................................................................................... 182
9.5 -index ........................................................................................................................... 183
9.6 Type Hierarchies .......................................................................................................... 186
9.6.1 The Need for a Type Hierarchy .......................................................................... 186
9.6.2 The Natural Type Hierarchy ............................................................................... 186
9.6.3 Adding to the Natural Hierarchy ........................................................................ 188
9.6.4 Restricting Down Assignments (-father) ............................................................ 189
9.6.5 Printing the Hierarchy Tree ................................................................................ 190
9.7 Hints on Strong Typing ................................................................................................ 191
9.8 Reference Information ................................................................................................. 193
9.9 Strong Types and Prototypes ....................................................................................... 194
III
10. VALUE TRACKING ........................................................................................................ 195
10.1 Initialization Tracking ................................................................................................ 195
10.2 Value Tracking .......................................................................................................... 198
10.2.1 The assert remedy ............................................................................................. 201
10.2.2 Interfunction Value Tracking ............................................................................ 203
10.2.3 Tracking Static Variables ................................................................................... 213
11. SEMANTICS ..................................................................................................................... 217
11.1 Function Mimicry (
-function) ................................................................................. 217
11.1.1 Special Functions .............................................................................................. 217
11.1.2 Function listing ................................................................................................. 221
11.2 Semantic Specifications (
-sem) ................................................................................. 227
11.2.1 Possible Semantics ............................................................................................ 227
11.2.2 Semantic Expressions ....................................................................................... 236
11.2.3 Notes on Semantic Specifications ..................................................................... 240
12. MULTI-THREAD SUPPORT ............................................................................................ 242
12.1 Overview ..................................................................................................................... 242
12.2 Identifying Threads ..................................................................................................... 242
12.3 Mutual Exclusion ........................................................................................................ 244
12.4 Thread-Protected (TP) Regions .................................................................................. 246
12.5 Constructor-triggered mutex locking .......................................................................... 247
12.6 Function Pointers ........................................................................................................ 248
12.7 Thread Unfriendly Functions ...................................................................................... 249
12.7.1 Thread Unsafe Functions (Category 1) .............................................................. 249
12.7.2 Category 2 Functions ......................................................................................... 251
12.7.3 Category 3 Functions ......................................................................................... 252
12.7.4 Header Options .................................................................................................. 252
12.7.5 Directory Options .............................................................................................. 253
12.7.6 Thread Unsafe Classifications ........................................................................... 253
12.7.7 Priorities in Thread Unsafety ............................................................................. 254
12.7.8 Category 4 Functions ......................................................................................... 255
12.7.9 Category 5 Functions ......................................................................................... 256
12.8 Thread Local Storage .................................................................................................. 256
12.8.1 __thread ............................................................................................................. 256
12.8.2 __declspec(thread) ............................................................................................. 256
12.9 Atomic Access ............................................................................................................ 257
12.9.1 Atomic Operations ............................................................................................. 257
12.9.2 Atomic Types ..................................................................................................... 258
12.10 Declarative Methods ................................................................................................. 260
13. OTHER FEATURES ......................................................................................................... 263
13.1 Order of Evaluation ................................................................................................... 263
13.2 Format Checking ........................................................................................................ 265
13.3 Indentation Checking ................................................................................................. 265
13.4 const Checking ........................................................................................................... 268
13.5 volatile Checking ....................................................................................................... 268
- 1
- 2
前往页