
November 2nd, 2012, 11:12 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 3
Time spent in forums: 33 m 11 sec
Reputation Power: 0
|
|
|
Python module build error. Compiler doesn't understand C++ syntax
I'm trying to build a Python module written in C++. In the module file I use C++ types I defined in other files and I include their header files in the C++ module file.
The problem I'm having is that when I build the module with my build script (listed below) I get errors implying that the compiler doesn't understand C++ syntax. I get the error listed below. I included the directory containing the types I use as include_dirs and library_dirs in the Extension command in my build script but that didn't help.
Here is the error I get:
===================================
Code:
running build
running build_ext
building 'xx' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c xxmodule.c -o build/temp.linux-x86_64-2.7/xxmodule.o
In file included from cdtm-model.h:4:0,
from xxmodule.c:19:
corpus.h:12:3: error: unknown type name ‘doc’
corpus.h:18:1: error: unknown type name ‘class’
corpus.h:18:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
In file included from xxmodule.c:19:0:
cdtm-model.h:6:1: error: unknown type name ‘class’
cdtm-model.h:7:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
cdtm-model.h:21:1: error: unknown type name ‘class’
cdtm-model.h:22:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
xxmodule.c: In function ‘xx_main_est’:
xxmodule.c:169:3: error: unknown type name ‘corpus’
xxmodule.c:169:15: error: ‘new’ undeclared (first use in this function)
xxmodule.c:169:15: note: each undeclared identifier is reported only once for each function it appears in
xxmodule.c:169:19: error: expected ‘,’ or ‘;’ before ‘corpus’
xxmodule.c:170:3: error: unknown type name ‘settings’
xxmodule.c:171:10: error: request for member ‘read_setting’ in something not a structure or union
xxmodule.c:170:12: warning: variable ‘setting’ set but not used [-Wunused-but-set-variable]
xxmodule.c:169:11: warning: unused variable ‘c’ [-Wunused-variable]
error: command 'gcc' failed with exit status 1
====================================
When I changed to in my header file, the compiler stopped complaining about having "unknown type name 'doc'". It seems like the compiler can't understand C++ syntax.
Here is my build script is:
Code:
from distutils.core import setup, Extension
cdtmmodule = Extension('xx',
library_dirs = ['/home/welshamy/workspace/cidtm/cdtm'],
sources = ['xxmodule.c'])
setup (name = 'cdtm',
version = '1.0',
description = 'This is the cDTM package',
ext_modules = [cdtmmodule])
|