Hi,
I need help.
I want use this API
LIB_EXTERN_C LIB_API long STDCALL method(
long id,
const double *vIN,
double *vOUT);
I use this syntaxe in c#
[DllImport("LIB.dll", EntryPoint="_method@12")]
public static extern long method(long idMethode, ref double [] vIn,
ref double[] vOUT);
double [] vIn = new double[10];
double [] vOUT= new double[10];
Main.method(1, ref vIn, ref vOUT);
I receive no error but the results it's bad...
vIn.Length == 1 and vOUT.Length == 1 and containt no data.
Thanks 4 1875
"J.M." <ja**************@gmail.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
Hi,
I need help.
I want use this API
LIB_EXTERN_C LIB_API long STDCALL method(
long id,
const double *vIN,
double *vOUT);
I use this syntaxe in c#
[DllImport("LIB.dll", EntryPoint="_method@12")]
public static extern long method(long idMethode, ref double [] vIn,
ref double[] vOUT);
Arrays are already pass-by-reference, you should try without "ref". The
function will not be able to resize the array (how could it? It knows
nothing about memory allocation in .NET)
>
double [] vIn = new double[10];
double [] vOUT= new double[10];
Main.method(1, ref vIn, ref vOUT);
I receive no error but the results it's bad...
vIn.Length == 1 and vOUT.Length == 1 and containt no data.
Thanks
If I removed the ref key word, I get no errors and no resizes on arrays
but the vOut array is empty.
On Jan 24, 12:49 pm, "Ben Voigt" <r...@nospam.nospamwrote:
"J.M." <jasmin.marine...@gmail.comwrote in messagenews:11**********************@s48g2000cws.g ooglegroups.com...
Hi,
I need help.
I want use this API
LIB_EXTERN_C LIB_API long STDCALL method(
long id,
const double *vIN,
double *vOUT);
I use this syntaxe in c#
[DllImport("LIB.dll", EntryPoint="_method@12")]
public static extern long method(long idMethode, ref double [] vIn,
ref double[] vOUT);Arrays are already pass-by-reference, you should try without "ref". The
function will not be able to resize the array (how could it? It knows
nothing about memory allocation in .NET)
double [] vIn = new double[10];
double [] vOUT= new double[10];
Main.method(1, ref vIn, ref vOUT);
I receive no error but the results it's bad...
vIn.Length == 1 and vOUT.Length == 1 and containt no data.
Thanks
"J.M." <ja**************@gmail.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
Hi,
I need help.
I want use this API
LIB_EXTERN_C LIB_API long STDCALL method(
long id,
const double *vIN,
double *vOUT);
I use this syntaxe in c#
[DllImport("LIB.dll", EntryPoint="_method@12")]
public static extern long method(long idMethode, ref double [] vIn,
ref double[] vOUT);
double [] vIn = new double[10];
double [] vOUT= new double[10];
Main.method(1, ref vIn, ref vOUT);
I receive no error but the results it's bad...
vIn.Length == 1 and vOUT.Length == 1 and containt no data.
Thanks
1. long in C# is 64 bit, long in C is 32 bit.
2. double *vOUT is a pointer to a double, you are passing a reference to an array which
results in extra dereferencing.
So your signature should look like....
public static extern int method(intidMethode, double [] vIn,
double[] vOUT);
and you should call it using...
Main.method(1, vIn, vOUT);
Willy.
Thanks,
The function execute perfectly.
"long in C == int in C# " ;-)
On Jan 24, 1:05 pm, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
"J.M." <jasmin.marine...@gmail.comwrote in messagenews:11**********************@s48g2000cws.g ooglegroups.com...
Hi,
I need help.
I want use this API
LIB_EXTERN_C LIB_API long STDCALL method(
long id,
const double *vIN,
double *vOUT);
I use this syntaxe in c#
[DllImport("LIB.dll", EntryPoint="_method@12")]
public static extern long method(long idMethode, ref double [] vIn,
ref double[] vOUT);
double [] vIn = new double[10];
double [] vOUT= new double[10];
Main.method(1, ref vIn, ref vOUT);
I receive no error but the results it's bad...
vIn.Length == 1 and vOUT.Length == 1 and containt no data.
Thanks1. long inC#is 64 bit, long inCis 32 bit.
2. double *vOUT is apointerto a double, you are passing a reference to an array which
results in extra dereferencing.
So your signature should look like....
public static extern int method(intidMethode, double [] vIn,
double[] vOUT);
and you should call it using...
Main.method(1, vIn, vOUT);
Willy.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: john smith |
last post by:
Hi, when there is a vector<> of pointers to some objects, does calling
resize cause vector to call delete on each object, or is there a memory leak
problem?
for example:
struct base {//some...
|
by: ip4ram |
last post by:
I used to work with C and have a set of libraries which allocate
multi-dimensional arrays(2 and 3) with single malloc call.
data_type **myarray
=...
|
by: TTroy |
last post by:
Hi,
I'm just wondering why people/books/experts say "the function returns a
pointer to.." or "we have to send scanf a pointer to.." instead of "the
function returns the address of.." or "we have...
|
by: Mark Jerde |
last post by:
I need to call a Win32 DLL. The API supports both Windows and Linux, but
I'm only concerned with Windows. I'd like advice whether I can use C# or
whether I'll have to dust off my old C++ books. ...
|
by: Kurt Van Campenhout |
last post by:
Hi,
I am trying to get/set Terminal server information in the active directory
on a windows 2000 domain. Since the ADSI calls for TS don't work until W2K3,
I need to do it myself.
I'm fairly...
|
by: mitchellpal |
last post by:
i am really having a hard time trying to differentiate the
two..........i mean.....anyone got a better idea how each occurs?
|
by: Abhishek |
last post by:
why do I see that in most C programs, pointers in functions are
accepted as:
int func(int i,(void *)p) where p is a pointer or an address which is
passed from the place where it is called. what...
|
by: xtrigger303 |
last post by:
Hi to all,
a newbie question. Is it possible to avoid the virtual mechanism with
pointers to members syntax the same way it's done with an explicit
call ( obj.Base::Func() )? It would be...
|
by: Nehil |
last post by:
Does C follow call by value convention or call by reference?
i see that there is nothing like reference in C standard but it is
referenced.
still, what should be the answer for the above...
|
by: Astley Le Jasper |
last post by:
Sorry for the numpty question ...
How do you find the reference name of an object?
So if i have this
bob = modulename.objectname()
how do i find that the name is 'bob'
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |