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

L A Walsh gcc@tlinx.org
Wed Mar 8 00:23:00 GMT 2017


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?

In this case, sure would be helpful.


----
//#include "src.h"

#include <ctype.h>

class X_interface {
	
#ifndef RM_BUG
	virtual void cpMtrGraphArea(int gx,int gy,unsigned W,unsigned H,int dstgx,int dstgy) {
		{copyArea(X()+gx, Y()+gy, W, H, X()+dstgx, Y()+dstgy);}
#endif
	
};

#include <cassert>


-----
Error:
> /usr/bin/g++ -c src.cc -o src.o 
In file included from /usr/include/features.h:378:0,
                 from /usr/include/ctype.h:25,
                 from src.cc:3:
/usr/include/assert.h:64:1: error: expected unqualified-id before string constant
 __BEGIN_DECLS
 ^
/usr/include/assert.h:83:1: error: expected ‘}’ at end of input
 __END_DECLS
 ^
src.cc: In member function ‘virtual void X_interface::cpMtrGraphArea(int, int, unsigned int, unsigned int, int, int)’:
src.cc:9:15: error: ‘X’ was not declared in this scope
   {copyArea(X()+gx, Y()+gy, W, H, X()+dstgx, Y()+dstgy);}
               ^
src.cc:9:23: error: ‘Y’ was not declared in this scope
   {copyArea(X()+gx, Y()+gy, W, H, X()+dstgx, Y()+dstgy);}
                       ^
src.cc:9:55: error: ‘copyArea’ was not declared in this scope
   {copyArea(X()+gx, Y()+gy, W, H, X()+dstgx, Y()+dstgy);}
                                                       ^
src.cc: At global scope:
src.cc:12:1: error: expected unqualified-id at end of input
 };
 ^



More information about the Gcc-help mailing list