I'm trying to include a C header file from an external library in my C+
+ program but when I compile I get the following error:
error: expected unqualified-id before 'private'
error: abstract declarator 'void*' used as declaration
error: expected ';' before 'private'
It didn't take me long to figure out that the offending C header file
uses a variable with the name "private". I've reproduced the problem
as follows:
/* -------- a.h - the C header file */
#ifndef TEST_H
#define TEST_H
struct s
{
void *private;
};
#endif
/* -------- end a.h */
/* -------- b.cpp - the C++ header file trying to include a.h */
extern "C" {
#include "a.h"
}
/* -------- end b.cpp */
I am compiling using this command:
%g++ -o b.o b.cpp
Despite enclosing the inclusion of the header file with extern "C",
the problem persists. As far as I know, 'private' is not a C key word
(confirmed by the fact that it compiles with the C compiler).
What am I doing wrong here?