다른 파일의 사용을 모방 한 특정 줄에서 오류가 발생합니다. 프로토 타입으로 PyChar_addGetSetter을 (정의 않습니다오류 : 예상되는 선언 지정자 또는 문자열 상수 앞에 '...'이 표시됨
#include <Python.h>
#include "../scripts/pychar.h"
을 그리고 pychar.h) :
PyObject *pyCharGetHeight(PyChar *self, void *closure) {
CHAR_DATA *ch = PyChar_AsChar((PyObject *)self);
PyObject *height = NULL;
if(ch != NULL) height = Py_BuildValue("s", charGetHeight(ch));
return height;
}
PyChar_addGetSetter("height", pyCharGetHeight, NULL, "Returns character's height");
내가 다음이 포함됩니다 사용하고
error: expected declaration specifiers or â...â before string constant
, PyChar_addGetSetter ... 라인 다음과 같은 오류를 반환 여기 :
void PyChar_addGetSetter(const char *name, void *g, void *s, const char *doc);
기능과 같이 ../scripts/pychar.c로 작성하면 다음과
void PyChar_addGetSetter(const char *name, void *g, void *s, const char *doc) {
// make sure our list of get/setters is created
if(pychar_getsetters == NULL) pychar_getsetters = newList();
// make the GetSetter def
PyGetSetDef *def = calloc(1, sizeof(PyGetSetDef));
def->name = strdup(name);
def->get = (getter)g;
def->set = (setter)s;
def->doc = (doc ? strdup(doc) : NULL);
def->closure = NULL;
listPut(pychar_getsetters, def);
}
이 인식되지 않는 구조 또는 형식처럼 보인다, 내 기능을 추측하고있다.
'PyChar_addGetSetter'는 C API의 함수가 아니므로 어디에서 왔습니까? (아마도 "../script/pychar.h"파일에서) 당신이 작성한 함수라면, 호출 코드와 프로토 타입뿐만 아니라 그 함수의 소스 코드를 보여 주어야합니다. (예를 들어, 버그는 쉽게'CHAR_DATA'가 길잃은 팸이나 뭔가있는 매크로 일 수 있습니다.) – abarnert
@abarnert 오류는 pychar.c 파일에 올라 오지 않으며 단지'PyChar_addGetSetter (" 높이 ", pyCharGetHeight, NULL,"문자의 높이를 반환합니다 ");가 포함되어 있으면 오류없이 다른 곳에서 사용됩니다. 가장 주목할만한 것은 pychar.c입니다. – ToothlessRebel