Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8612519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:38:50+00:00 2026-06-12T04:38:50+00:00

Here is my c++ code: struct Impl { DT* data_ptr_; Impl(void* data_ptr) : data_ptr_((DT*)data_ptr)

  • 0

Here is my c++ code:

struct Impl
{
  DT* data_ptr_;

  Impl(void* data_ptr)
    : data_ptr_((DT*)data_ptr)
  {
    //do something to decipher data
  }
};

Impl class takes a void pointer, as a input parameter.

What I want to do is just pass a Python string(binary string as in Python 2.x) as parameter:

data = "I'm a stirng data!"
impl = Impl(data)

But Swig generated module raises this

TypeError: in method 'new_Impl', argument 1 of type 'void *'

I’m new to swig and have searched in SWIG documentation for a whole day now.
The only thing worked for me is in swig document 8.3 C String Handling. But my function don’t really take a size integer.

I think my problem is rather simple, I must missed something, please help.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:38:51+00:00Added an answer on June 12, 2026 at 4:38 am

    I found a solution myself.

    As I only needed the void* pointer as input:

    %typemap(in) void* = char*;
    

    will do the trick.

    Swig accept char* parameter as string type, and take void* just as an pointer.
    so use the char* input type will be okay.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code doesn't build. struct some_struct { some_struct() { ... do something here
Here is my example code which produces the error: struct Impl { int data_size_;
I have something like the folowing C code: struct MyStruct MyFunction (something here) {
In FastCGI, there is a pointer, envp, of struct FCGX_Request. Here is the code
Here's the scenario: template <template <typename> class T, typename V> struct parent { void
Here is my code : typedef struct node { int data; struct node *next;
Here is my code: typedef struct TItemSelector{ ItemSelectFrame* pItems[2]; } SItemSelector; class item {
I need to read certain statistics from iw_statistics structure, here's the code: struct net_device
So here's a snippet of my code: struct dv_nexthop_cost_pair { unsigned short nexthop; unsigned
where is the mistake? My code here: typedef struct _box { char *dados; struct

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.