example does not compile, look like a bug

Hi ALl,

I was not sure where to post this.
there is an example...tutorial on using clang library
https://github.com/loarabia/Clang-tutorial/blob/master/CItutorial4.cpp

When I use VIsual Stuidio 2013 compiler, some of the headers files do not
compile.
d:\src\llvm-3.6.0.src\tools\clang\include\clang/AST/DeclBase.h(1142) : error
C2039: 'Captured' : is not a member of 'clang::Decl'
        d:\src\llvm-3.6.0.src\tools\clang\include\clang/AST/DeclBase.h(72) :
see declaration of 'clang::Decl'
d:\src\llvm-3.6.0.src\tools\clang\include\clang/AST/DeclBase.h(1142) : error
C2065: 'Captured' : undeclared identifier
d:\src\llvm-3.6.0.src\tools\clang\include\clang/AST/DeclBase.h(1142) : error
C2051: case expression not constant

When is it fixed? Or what is this?

Thanks in advance.

Marton

According to https://github.com/loarabia/Clang-tutorial it was not
updated for more than a year. It does make perfect sense that it
cannot be compiled with 3.6 release.

You may want to ask the author of that code to fix it, or fix yourself.

Thanks you for trying to help.
This problem is located in clang headers , not in the code as I see it.
It implies clang 3.6.0 was released with faulty headers???

Marton

(snipped)

Thanks you for trying to help.
This problem is located in clang headers , not in the code as I see it.
It implies clang 3.6.0 was released with faulty headers???

Marton

Unlikely.

The tutorial code was written for the clang 3.4.0 headers. The clang
headers have changed since the 3.4.0 release, but the tutorial code
was not updated.

Csaba

As a reminder, the samples here:
https://github.com/eliben/llvm-clang-samples
Are kept up-to-date with upstream LLVM & Clang. There are branches for each
LLVM release, and the master branch tracks ToT (usually no more than a
couple of weeks behind). The samples come with a full Makefile for Linux
that can be used to build them vs. a source tree of LLVM & Clang or a
binary drop.

Eli

It is not clear what you mean that headers "changed"...
I downloaded 3.6.0 headers from the official site as a part of clang source package.
#include "clang/AST/ASTContext.h"
This is the line causing the error. This seems to be a valid header.
I can find it in the documentation.

Marton

Clang and LLVM does not guarantee that “everything is compatible from one release to another”. In fact, you can almost guarantee that anything reasonably complex will NOT be compatible.

So, if try to build an old example, that is written for 3.4, with a 3.6 compiler installation, it won’t compile.

This is “by design” in the sense that keeping compatibility between releases is a lot of hard work, especially if you actually wish to improve the product between one release and the next.

There are three ways to solve your problem:

  1. Find an updated example that matches the compiler you are using.
  2. Get the older version of compiler and build against that instead of the latest release.
  3. Fix the code that has become out of date. This will not only solve the problem, but you are likely to learn how things work better - but sometimes it’s not trivial.

(If the problem is that a header can’t be found, then you probably simply need to update the -I option for the build)