problem in gcc (lib) headers __BEGIN_DECLS & traceback-incomplete

Jonathan Wakely jwakely.gcc@gmail.com
Wed Mar 8 00:26:00 GMT 2017


On 8 March 2017 at 00:23, L A Walsh wrote:
> Jonathan Wakely wrote:
>
>> Reduce your code to the minimum necessary to show the problem, and
>> paste that here. If as you say, there is nothing before the includes,
>> you shouldn't need to paste any of your code, just two files
>> containing nothing but include directives. We can't reliably guess
>> what your code does.
>
> ----
>
> Here it is, there is a source error in a .h file, but it and an include of
> '<cassert>' were behind 2-3 levels of includes.  In this case, the missing
> '}' is shown immediately after the __BEGIN_DECLS prob, but it wasn't that
> way with all the other includes (if it was shown at all).
>
> So why doesn't it show the missing '}' before the __BEGIN_DECLS error when
> the missing '}' occurs before the include of cassert?

Because it's valid to do:

struct X {
#include "foo.h"
};

Or even:

struct Y {
#include "bar.h"

where the closing brace is in bar.h

So the compiler can't give an error before the include, because the
header might provide the closing brace.



More information about the Gcc-help mailing list