Click on image to see enlargment

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

            bug452.mm

@header flowers.h
1    #include 
2    #include 
3    void flower_info(void);
@module flowers.cpp
1    #include "flowers.h"
2    typedef int N;
3    extern struct Flower_Data
4        { N count; } flwrs;
5    int main()
6        {
7        flower_info();
8        printf( "%d\n" , flwrs.count );
9        return 0;
10       }
@module f_data.cpp
1    #include "flowers.h"
2    typedef float N;
3    struct Flower_Data
4        { N count; } flwrs;
5    void flower_info()
6        {
7        // As a test we'll just do a count
8        flwrs.count = 123;
9        }

Flo, a master florist, is automating her floral arrangements. In one module, flower_info() is gathering information and the main program is processing it. But as a simple example, shown here, a small flower count, when printed, balloons into a gigantic number. Can you spot the problem?


bug452.mm lint Output


=== Multiple Modules: bug452.mm

--- Module:   flowers.cpp (C++)

--- Module:   f_data.cpp (C++)
                  _
    typedef float N;
f_data.cpp(2) : Warning 452: typedef Symbol 'N' redeclared (basic) conflicts
    with line 2, file flowers.cpp
                   _
        { N count; } flwrs;
f_data.cpp(4) : Warning 631: tag 'Flower_Data' defined differently at line 3,
    file flowers.cpp
f_data.cpp(4) : Error 18: Symbol 'flwrs' redeclared (basic) conflicts with line
    4, file flowers.cpp

Reference Manual Explanation


452    typedef Symbol 'Symbol' redeclared (TypeDiff) conflicts with Location  -- A typedef symbol is being
       declared to be a different type.  This can be legal, especially with multiple modules, but is not good
       programming practice.  It inteferes with program legibility.


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


Previous Bug - Bug #413 - April 2012

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 2012, Gimpel Software, All rights reserved.