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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:08:57+00:00 2026-05-28T00:08:57+00:00

I have a native library with some native ntype in it and would like

  • 0

I have a native library with some native ntype in it and would like to p/invoke some functions in it.

I was able to marshal for:

foo1(ntype** p) ==> foo1(IntPtr[] p)

But don’t know how to do it for:

foo1(ntype*[] p) ==> foo1(<???> p)

At least IntPtr[] did not worked.

Edit

The unmanaged function I’m trying to marshal with is:

extern mxArray* mclCreateSimpleFunctionHandle(mxFunctionPtr fcn);

where mxFunctionPtr is:

typedef void(*mxFunctionPtr)(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]);

This represent a call to the following matlab function signature:

function [varargout] = callback(varargins)
%[
    %% Do callback code %%
%]

Obviously, from my expectations, this function pointer should provide me with 2 lists of mxArray*:

  • The list of input arguments (i.e. prhs, initialized on matlab’s side)
  • The list of output arguments (i.e. plhs, all initialized to zero but in which I should write into)

Currently from the tests I’ve made, it only returns for firsts mxArray* in plhs and prhs lists

  • 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-28T00:08:57+00:00Added an answer on May 28, 2026 at 12:08 am

    Got it

    The correct marshalling for ‘SomeTime* []‘ in:

    extern mxArray* mclCreateSimpleFunctionHandle(mxFunctionPtr fcn);
    typedef void(*mxFunctionPtr)(int nlhs, mxArray* plhs[], int nrhs, mxArray* prhs[]);
    

    is:

    // For function pointer
    [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
    public delegate void MCRInteropDelegate(int nlhs,
                                            [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.SysInt, SizeParamIndex = 0)][Out] IntPtr[] plhs, 
                                            int nrhs,
                                            [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.SysInt, SizeParamIndex = 2)][In] IntPtr[] prhs);
    
    // For API function
    [DllImport(DLLNAME, EntryPoint = "mclCreateSimpleFunctionHandle", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
    private static extern IntPtr _mclCreateSimpleFunctionHandle(MCRInteropDelegate fctn);
    

    Explanation

    MarshalAs attribute indicates to marshal SomeTime*[] as a LPArray of IntPtr, where the size of the array is contained by function’s parameter at the zero-based index SizeParamIndex

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

Sidebar

Related Questions

I have heard of WINE but I don't like it because it's slow on
I have an Android java library that uses some native code. I have added
Lets say we have a native library that works with data like this: double
I have a Java program making some JNI calls to a native library (mylib.so).
I have an native C++ dll, some header files and the import library. Is
so I have some 3rd party native library that works only in 32 bit
This is probably a multi-part question. Background: we have a native (c++) library that
I have a managed dll that calls into a native library. This native library
I have an existing library (JPhysX) that is a Java wrapper for a native
I know that PHP doesn't yet have native Enumerations. But I have become accustomed

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.