Issues with traversal

Hi there,
So I have finally gotten back to working on my translation code which
attempts to walk an AST and create a new syntactic structure from the
nodes for later analysis. I have a few issues which I was hoping
someone could help solve.
Right now I have a simple little code example which I run this on:

#include <iostream>

int inone = 4;
const unsigned int b = 3;

int dosome(int a){
  int c = 3;
  a = a + 7;
  return a + c;
}

int main()
{
  int input = 5;
  dosome(input);
  std::cout<< "Hello World\n";
  for(int i = 0; i < 3; i++)
    {
      input += 5;
    }
  return 0;
}

1. The first issue is regarding the include statement at the top. In
general when I leave it I usually get some error about a header file
not being found or certain items not being found.

In file included from test.cpp:1:
In file included from /usr/include/c++/4.4.4/iostream:39:
In file included from /usr/include/c++/4.4.4/ostream:39:
In file included from /usr/include/c++/4.4.4/ios:38:
In file included from /usr/include/c++/4.4.4/iosfwd:41:
In file included from /usr/include/c++/4.4.4/bits/postypes.h:41:
In file included from /usr/include/c++/4.4.4/tr1/cwchar:46:
/usr/include/c++/4.4.4/tr1_impl/cwchar:37:14: error: no member named
'wcstof' in namespace 'std'
  using std::wcstof;
        ~~~~~^
/usr/include/c++/4.4.4/tr1_impl/cwchar:40:14: error: no member named
'vfwscanf' in namespace 'std'
  using std::vfwscanf;
        ~~~~~^

....

or from another error:
...
/usr/include/c++/4.4.4/bits/postypes.h:214:12: error: unknown type name 'bool'
    inline bool
             ^
....

I suspect that this is an initial configuration problem. I have
included in my application a number of AddPath statements (to
...c++/4.4.4/...).
In my setup of clang I included the standard directories as well (to
/usr/include/linux , /usr/include/c++/4.4.4/ ...)
Is there something that I missing here?

2. The result of my rather little tree traversal code is approximately
250 MB in size. Far be it from me to say that this is too big but it
does seem very large. Is there possibly something off about my
configuration that would create such a binary? Here is my compile
command:

g++ example.cpp -g -o example.out `llvm-config --cxxflags`
-I/usr/local/include -I/usr/include -lclangFrontendTool
-lclangFrontend -lclangDriver -lclangSerialization -lclangCodeGen
-lclangParse -lclangSema -lclangAnalysis -lclangIndex -lclangRewrite
-lclangAST -lclangLex -lclangBasic `llvm-config --ldflags --libs`

I probably have a few things in there that are not needed and have
tried to cull a few of them. (I get compile errors.) I did my initial
build with out the optimize switch. Would that make a difference here?

Thanks,
Josef

/usr/include/c++/4.4.4/bits/postypes.h:214:12: error: unknown type name 'bool'
     inline bool
              ^

Filenames that end in .h are parsed in c-mode (as opposed to c++ mode) by default leading to such errors.

You can force c++ mode by passing "-x c++" to the parser, followed by the files you want to parse in c++ mode. (Alternatively you can rename a .h file to a .hpp file, but given that you are using system header files, that probably is a bad idea).

Note: just passing on what someone told me a few weeks ago. I'm by no means an expert. It worked for me though.

HTH,
Stefaan.

There isn't a "C mode" for headers. The only piece of magic is that a C
system header location gets an implicit extern "C" {} wrapper and C++
system header location doesn't. That's irrelevant for bool though.

Joerg