Click on image to see enlargment

PC-lint/FlexeLint Output | Reference Manual Explanation | Home

            bug553.cpp

1    #include <stdio.h>
2    #define DOCTORATE 1
3    #define CHOICE 2
4    const char *a[2][3] =
5        {
6        {"Hitler", "Stalin", "Bin Laden"},
7        {"Clinton", "Bush", "Powell" }
8        };
9    int main()
10       {
11       const char **array;
12   #if D0CT0RATE
13       array = a[1];
14   #else
15       array = a[0];
16   #endif
17       printf( "An honorary doctorate award "
18         " is issued to %s\n",
19         array[CHOICE] );
20       }

There were a lot of red faces at the university when an honorary degree was awarded to a Mr. Bin Laden. What went wrong?


bug553.cpp lint Output

--- Module:   bug553.cpp (C++)
    _
#if D0CT0RATE
bug553.cpp(12) : Warning 553: Undefined preprocessor variable 'D0CT0RATE', assumed 0

    --- Wrap-up for Module: bug553.cpp

Info 750: local macro 'DOCTORATE' (line 2, file bug553.cpp) not referenced

Reference Manual Explanation


553    Undefined preprocessor variable 'Name', assumed 0   -- The
       indicated variable had not previously been defined within a
       #define statement and yet it is being used in a preprocessor
       condition of the form #if or #elif.  Conventionally all variables
       in preprocessor expressions should be pre-defined.  The value of
       the variable is assumed to be 0.


If you have comments or questions about this bug, please post them to our   Discussion Forum


Previous Bug - Bug #571 - May 2008

Use our Interactive Demo to Run FlexeLint on our Bugs of the Month

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

PC-lint and FlexeLint are trademarks of Gimpel Software
Copyright 2009, Gimpel Software, All rights reserved.