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

  • SEARCH
  • Home
  • 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 8503353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:44:08+00:00 2026-06-11T01:44:08+00:00

I have a SWIG module where I want to add a hand-rolled method. %module

  • 0

I have a SWIG module where I want to add a hand-rolled method.

%module frob

%inline %{

    int Foo(int x, int y) { return x+y; }

    PyObject* Bar(PyObject* self, PyObject* args) {
        return PyString_FromString("Hello from Bar");
    }
%}

However, when I ran swig over it swig -python frob.i, I saw that SWIG actually wrapped both Foo and Bar as _wrap_Foo, _wrap_Bar.

 SWIGINTERN PyObject *_wrap_Foo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   // ...
   result = (int)Foo(arg1,arg2);
   // ...
 }    
 SWIGINTERN PyObject *_wrap_Bar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   // ...
   result = (PyObject *)Bar(arg1,arg2);
   // ... 
}

How do I tell SWIG to stop wrapping Bar for me, but just expose it in the PyMethodDef table?

  • 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-11T01:44:10+00:00Added an answer on June 11, 2026 at 1:44 am

    To exclude a function from being wrapped, use the %native directive.

    %module "test"
    
    /* Prototype */    
    %native(DontWrapMeBro)
    PyObject* DontWrapMeBro(PyObject* self, PyObject* args);
    
    %{
      PyObject* DontWrapMeBro(PyObject* self, PyObject* args)
      {
        return PyString_AsString("Don't wrap me");
      }
    %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have swig.i file like that: %module ogr_api %{ #include ogr_api.h %} %inline %{
I have a python module that imports a module generated with swig. When I
I used SWIG to generate a Perl module for a C++ program. I have
I have a SWIG generated function as follows: SWIGINTERN PyObject *_wrap_StrVector___getitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args)
I have the following code wrapped by swig: int cluster::myController(controller*& _controller) { _controller =
I have a C function that I want to call using Java via SWIG
I have a c++ file that I want to turn into a Python module
I have a sub in perl (generated automatically by SWIG) that I want to
OK so I have a C++ class that is exposed to Lua using SWIG.
While going through SWig generated wrappers, I find that the PInvokes don't have any

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.