English 中文(简体)
类型:无法以双点争辩为包裹功能
原标题:TypeError: unable to acces a wrapped function with double pointer argument

在以两点为理由获取一种功能时,不要忘记和去掉一种奇怪的类型。

我的档案如下:

例:hpp

#ifndef _EXAMPLE_HPP
#define _EXAMPLE_HPP

class Example {
public:
    void test_cc(char * c0, char * c1);
    void test_cd(char * c0, double d0);
    void test_cdp(char * c0, double * d0);
};

#endif // _EXAMPLE_HPP

例.cpp

#include "例:hpp"

void Example::test_cc(char * c0, char * c1) {}
void Example::test_cd(char * c0, double d0) {}
void Example::test_cdp(char * c0, double * d0) {}

%module Example
%{
#include "例:hpp"
%}

#include "例:hpp"

and finally my testfile test_Example.py:

#!/usr/bin/env python

import Example

E = Example.Example()

E.test_cc("Hello","World");
E.test_cd("Hello",42);
E.test_cdp("Hello",42);

When i run ./test_Example.py, i get the Error Message

Traceback (most recent call last):
  File "./test_Example.py", line 9, in <module>
    E.test_cdp("Hello",42);
  File "Example.py", line 77, in test_cdp
    def test_cdp(self, *args): return _Example.Example_test_cdp(self, *args)
TypeError: in method  Example_test_cdp , argument 3 of type  double * 

获取功能测试—— ccwork, 测试_cd ......为什么不测试_cdp?

我的错误在哪里?

问题回答

我认为,你的问题实际上在于:

void test_cd(char * c0, double * d0);

and that your argument should be a double, not a double*.

www.un.org/Depts/DGACM/index_spanish.htm 参见您的评论。

Your code is:

E.test_cc("Hello","World");
E.test_cd("Hello",42);

Your prototypes are:

void test_cc(char * c0, char * c1);
void test_cd(char * c0, double d0);

“Hello”和“World”正在用字面来说明,这种字面被打上了星号。 因此,他们是点人。 当你通过0和c1测试时,会因期望某个点而获得罚款。

虽然0分辨率是检测点,但0分辨率不是,0分辨率是双倍,NOT点到杜里。 因此,你必须顺从两倍。

你们可以这样做,要么在 st上翻一番,要么在讲话中通过:

double hi_mom = 83.2;
test_cd("some string" &hi_mom);

或宣布点名并指明点数变量,即:

double hi_mom = 83.2;
double* ptr = &hi_mom;
test_cd("some string", ptr);

或宣布点号为动态记忆,并通过:

double* ptr = new double(83.2);
test_cd("some string", ptr);
delete ptr;

虽然我可以避免第3次。

www.un.org/Depts/DGACM/index_spanish.htm Edit re...

rel=“nofollow”http://www.dalkescientific.com/evens/NBN/c_extensions.html

shows a working example of how to call C code from python including passing a double. Search for iterate_point in both the python and C code to see how it works. You shouldn t have a pointer for the double, it should just be a normal double as said earlier.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签