3

I am trying to lint my project. But it seems like Lint is unable to recognize the classes such as std::string, std::vector and std::queue. I am using lib-std.lnt config file as well but of no use, facing the errors like following.

Error 40: Undeclared identifier 'queue'

Error 40: Undeclared identifier 'string'

Error 10: Expecting a structure or union

Does any one know how to resolve the issue?


for sample code :-

#include<string>

int main(void) 
{
    std::string str;  
    return ;
}

=================================== and the out put is as following


/>lint-nt -iC:\ghs\comp_20121\ansi  proj2.lnt snip.cpp
PC-lint for C/C++ (NT) Vers. 8.00x, Copyright Gimpel Software 1985-2008

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

typedef wchar_t _Wchart;

C:\ghs\comp_20121\scxx\yvals.h:747  Warning Error 10: Expecting ';'

C:\ghs\comp_20121\scxx\yvals.h:747  Warning Error 19: Useless Declaration

std::string str;

snip.cpp:4  Warning Error 40: Undeclared identifier 'string'

snip.cpp:4  Warning Warning 522: Expected void type, assignment, increment or decrement

snip.cpp:4  Warning Error 10: Expecting ';'
StellarVortex
  • 576
  • 4
  • 19
M.Ali
  • 101
  • 1
  • 5
  • What extension are you using for your C++ files? Non-'Standard' ones have to be made known to PC- (I hope) Lint... – Johan Bezem Feb 12 '13 at 19:40
  • Johan,I am using .cpp files. and yes it is PC-Lint v8.00w from Gimpel. – M.Ali Feb 12 '13 at 20:19
  • Run lint with the additional option `-voif` (careful, large output) and look if (1) Lint finds all includes at the locations you want them found, and (2) that all modules are interpreted as C++, not C. And see if your environment contains the `INCLUDE` environment variable, possibly misleading Lint (e.g. when VS2010 is installed, but you're using the GNU compiler...). – Johan Bezem Feb 13 '13 at 07:13
  • BTW, update to 8.00x (it's free of charge, see http://www.gimpel.com/html/ptch80.htm, the patches' page for version 8.0. From the release notes: "There was an outside chance that a second module would think that a class did not have members when it really did. The class in question was a template class embedded in a template class RPUS, 8/14/07"; it might apply to your case. – Johan Bezem Feb 13 '13 at 10:30
  • Is it possible to provide a small but complete sample program that Lint will not parse? And to provide a link to the `-voif`-enhanced output? One thing you may try for yourself is to run Lint's preprocessor only, using the option `-p`, and check what Lint produces in those locations where the problems seem to occur. – Johan Bezem Feb 14 '13 at 05:49
  • OK; I guess the customs of these sites would want your files/results better as edits to your post, better than 'wasting' so many comments in a confusing way, but I understand the results. Since GHS seems to define its own `wchar_t`, whereas Lint has its built-in type, please use the option `-fwc` to switch the built-in off. That could very well be the culprit. Then edit your post to include the samples, delete the comments, and I'll post this as an answer so you may tick this as _the_ answer ;) – Johan Bezem Feb 14 '13 at 21:03
  • Slight oops: Please use `-fwc --fwc` instead (yes, twice, with the second a double minus), to switch the built-in off for both C and C++. See the manual on pages 77-78... – Johan Bezem Feb 14 '13 at 21:12

0 Answers0