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 7659747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:22:25+00:00 2026-05-31T13:22:25+00:00

I am working with ctypes using C++ as the backend. Now there is a

  • 0

I am working with ctypes using C++ as the backend. Now there is a function like this in C++:

void HandleString(std::string something){

   ...
}

I am wondering how to call this function from python – there is no ctype (c_char_p wont work obviously) to send a string parameter to this function…

How can I fix this and pass a string from Python to c++ (and changing the parameter to char* something is not and option)

PS Could I create a workaround like this?

  1. send the python string as c_char_p to C++ function that converts char* to std::string
  2. return the string or its pointer somehow???!! (how?) to python
  3. send it from python to HandleString function (but again I feel like I would have to change the parameter to string* here)
  • 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-05-31T13:22:25+00:00Added an answer on May 31, 2026 at 1:22 pm

    Sounds like the simplest approach is to write a thin c++ wrapper around the library for the sole purpose of renegotiating the parameters from python into the more complex c++ classes.

    Such an approach would also help remedy future problems of the same kind, without adding any real complexity to neither the python code or the c++ code.

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

Sidebar

Related Questions

I am working with some C code called from Python using ctypes. Somewhere in
Using the following code: Function GetSetting(Of T)(ByVal SettingName As String, ByRef DefaultVal As T)
#include <iostream> #include <ctype.h> using namespace std; void isPalindrome(); int main() { char response;
Is there a way to simplify this working code? This code gets for an
I'm sure there is an answer to this somewhere but I'm clearly using the
I am having trouble building a working version of Python with ctypes using the
I'm using ctypes and I've defined this struct in order to pass parameters class
(there is a follow up to this question here ) I am working on
Working on a website that has Employee and Branch entities, using a database table
Working on a page with multiple sections. at the very top there is a

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.