473,587 Members | 2,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

exporting a struct with an array from a C++ dll to be accessed in C#

AM
Hi,
I have a C++ Dll that has a function that is being exported as
shown below

extern "C" __declspec(dlle xport) validationResul t __stdcall
_validateData(d ouble dataToMat[], int time);

A structure is defined in the header(.h file) as shown below
struct validationResul t
{
int rWaveValid; //validity of the WAVE
int signalStatusArr ay[4]; //validity of each of the channel data -
'causing the problems'
};

I need to call the above method from C# in where i have the following
structure defined
public struct validationResul t
{
public int micDataValid; //validity of the microphone data
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
channel data
};

And my function call is as shown
validationResul t res = new validationResul t();
res.signalStatu sArray = new int[4];
res = _validateData(d ataToMat, 2);

When the last line is reached i get an exception that says"Method's
type signature is not PInvoke compatible"
What am I doing wrong.

I know the issue is at the array inside the struct, as when I remove
the array from the C++ struct and the C# struct I get the right
response.

Thanks in Advance.
abhi M

Apr 18 '07 #1
9 6514

"AM" <ab********@gma il.comwrote in message
news:11******** *************@o 5g2000hsb.googl egroups.com...
Hi,
I have a C++ Dll that has a function that is being exported as
shown below

extern "C" __declspec(dlle xport) validationResul t __stdcall
_validateData(d ouble dataToMat[], int time);

A structure is defined in the header(.h file) as shown below
struct validationResul t
{
int rWaveValid; //validity of the WAVE
int signalStatusArr ay[4]; //validity of each of the channel data -
'causing the problems'
};

I need to call the above method from C# in where i have the following
structure defined
public struct validationResul t
{
public int micDataValid; //validity of the microphone data
magically appeared?
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
channel data
No, that doesn't match. A dynamically resizeable array is not the same as
an inline array of size 4. Look for the 'fixed' keyword in the C# help.
};

And my function call is as shown
validationResul t res = new validationResul t();
res.signalStatu sArray = new int[4];
res = _validateData(d ataToMat, 2);

When the last line is reached i get an exception that says"Method's
type signature is not PInvoke compatible"
What am I doing wrong.

I know the issue is at the array inside the struct, as when I remove
the array from the C++ struct and the C# struct I get the right
response.

Thanks in Advance.
abhi M

Apr 18 '07 #2
AM
I guess i did not copy my code correctly.
Here is what my C# struct looks like

public struct validationResul t
{
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
//channel data
};

Are you suggesting that the the error is caused by my array definition
in C# is dynamic (because of the []), while my C++ array is of size 4?

On Apr 18, 2:01 pm, "Ben Voigt" <r...@nospam.no spamwrote:
"AM" <abhi.me...@gma il.comwrote in message

news:11******** *************@o 5g2000hsb.googl egroups.com...
Hi,
I have a C++ Dll that has a function that is being exported as
shown below
extern "C" __declspec(dlle xport) validationResul t __stdcall
_validateData(d ouble dataToMat[], int time);
A structure is defined in the header(.h file) as shown below
struct validationResul t
{
int rWaveValid; //validity of the WAVE
int signalStatusArr ay[4]; //validity of each of the channel data -
'causing the problems'
};
I need to call the above method from C# in where i have the following
structure defined
public struct validationResul t
{
public int micDataValid; //validity of the microphone data

magically appeared?
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
channel data

No, that doesn't match. A dynamically resizeable array is not the same as
an inline array of size 4. Look for the 'fixed' keyword in the C# help.
};
And my function call is as shown
validationResul t res = new validationResul t();
res.signalStatu sArray = new int[4];
res = _validateData(d ataToMat, 2);
When the last line is reached i get an exception that says"Method's
type signature is not PInvoke compatible"
What am I doing wrong.
I know the issue is at the array inside the struct, as when I remove
the array from the C++ struct and the C# struct I get the right
response.
Thanks in Advance.
abhi M

Apr 18 '07 #3
"AM" <ab********@gma il.comwrote in message
news:11******** **************@ n59g2000hsh.goo glegroups.com.. .
>I guess i did not copy my code correctly.
Here is what my C# struct looks like

public struct validationResul t
{
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
//channel data
};

Are you suggesting that the the error is caused by my array definition
in C# is dynamic (because of the []), while my C++ array is of size 4?
Hard to tell, as you did not post the function declaration (C#), also I'm not clear on why
you allocate a managed array in C# while your C function returns a pointer (to an array in
unmanaged memory).

res.signalStatu sArray = new int[4]; // WHY????
res = _validateData(d ataToMat, 2); //res is returned from C, it's a pointer right???

I would suggest you to post a complete sample that illustrates the issue.
Willy.
Apr 18 '07 #4
AM
Here is my C++ code

#include "CppMatlabWrapp er.h"
#include <exception>
#include <string>
using namespace std;

//Method to validate the data
extern "C" __declspec(dlle xport) validationResul t __stdcall
_validateData(d ouble dataToMat[], int time)
{
validationResul t res;
res.signalStatu sArray[0]=1;
res.signalStatu sArray[1]=2;
res.signalStatu sArray[2]=3;
res.signalStatu sArray[3]=4;
res.micDataVali d = (int)(dataToMat[0]*100);
res.rWaveValid = (int)(dataToMat[1]*100);
return res;
}

------------
Here is the header file CppMatlabWrappe r.h
//Structure to store the result of the validation operation
struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
int signalStatusArr ay[4]; //validity of each of the channel data
};
extern "C" __declspec(dlle xport) validationResul t __stdcall
_validateData(d ouble dataToMat[], int time);

This C++ code compiled gives me the library "CppMatlabWrapp er.dll"
--------------------------------------------------------------------

Here is the C# code to access this library
using System;
using System.Runtime. InteropServices ;

namespace MatlabWrapper
{
class Program
{

//Structure to receive the result of the validation operation
public struct validationResul t
{
public int micDataValid; //validity of the microphone data
public int rWaveValid; //validity of the r Wave
public fixed int signalStatusArr ay[4];
};

[DllImport("CppM atlabWrapper.dl l")]
static extern validationResul t _validateData(d ouble[] data,
int time);

static void Main(string[] args)
{
//code for creating a double array called dataToMat of
some size
//
validationResul t res;
res = _validateData(d ataToMat, 2);
}
}
}
THANKS
________

On Apr 18, 5:08 pm, "Willy Denoyette [MVP]"
<willy.denoye.. .@telenet.bewro te:
"AM" <abhi.me...@gma il.comwrote in message

news:11******** **************@ n59g2000hsh.goo glegroups.com.. .
I guess i did not copy my code correctly.
Here is what my C# struct looks like
public struct validationResul t
{
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
//channel data
};
Are you suggesting that the the error is caused by my array definition
in C# is dynamic (because of the []), while my C++ array is of size 4?

Hard to tell, as you did not post the function declaration (C#), also I'm not clear on why
you allocate a managed array in C# while your C function returns a pointer (to an array in
unmanaged memory).

res.signalStatu sArray = new int[4]; // WHY????
res = _validateData(d ataToMat, 2); //res is returned from C, it's a pointer right???

I would suggest you to post a complete sample that illustrates the issue.

Willy.

Apr 19 '07 #5

"AM" <ab********@gma il.comwrote in message
news:11******** **************@ n59g2000hsh.goo glegroups.com.. .
>I guess i did not copy my code correctly.
Here is what my C# struct looks like

public struct validationResul t
{
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
//channel data
};

Are you suggesting that the the error is caused by my array definition
in C# is dynamic (because of the []), while my C++ array is of size 4?
I am suggesting looking at the documentation for C# fixed-size buffers which
is here: http://msdn2.microsoft.com/en-us/lib...ya(VS.80).aspx

A dynamic (.NET) array carries additional stuff with it like length.
Additionally, since .NET arrays are ref class, only a pointer is stored in
the structure. This is totally different from the layout used by the C++
structure definition you gave.
>
On Apr 18, 2:01 pm, "Ben Voigt" <r...@nospam.no spamwrote:
>"AM" <abhi.me...@gma il.comwrote in message

news:11******* **************@ o5g2000hsb.goog legroups.com...
Hi,
I have a C++ Dll that has a function that is being exported as
shown below
extern "C" __declspec(dlle xport) validationResul t __stdcall
_validateData(d ouble dataToMat[], int time);
A structure is defined in the header(.h file) as shown below
struct validationResul t
{
int rWaveValid; //validity of the WAVE
int signalStatusArr ay[4]; //validity of each of the channel data -
'causing the problems'
};
I need to call the above method from C# in where i have the following
structure defined
public struct validationResul t
{
public int micDataValid; //validity of the microphone data

magically appeared?
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
channel data

No, that doesn't match. A dynamically resizeable array is not the same
as
an inline array of size 4. Look for the 'fixed' keyword in the C# help.
};
And my function call is as shown
validationResul t res = new validationResul t();
res.signalStatu sArray = new int[4];
res = _validateData(d ataToMat, 2);
When the last line is reached i get an exception that says"Method's
type signature is not PInvoke compatible"
What am I doing wrong.
I know the issue is at the array inside the struct, as when I remove
the array from the C++ struct and the C# struct I get the right
response.
Thanks in Advance.
abhi M


Apr 19 '07 #6
AM
In that case what should my C# definition look like for the
corresponding C++ definition mentioned below?

C++ struct
struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
int signalStatusArr ay[4]; //validity of each of the channel
data
};

Thanks

On Apr 19, 10:31 am, "Ben Voigt" <r...@nospam.no spamwrote:
"AM" <abhi.me...@gma il.comwrote in message

news:11******** **************@ n59g2000hsh.goo glegroups.com.. .
I guess i did not copy my code correctly.
Here is what my C# struct looks like
public struct validationResul t
{
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
//channel data
};
Are you suggesting that the the error is caused by my array definition
in C# is dynamic (because of the []), while my C++ array is of size 4?

I am suggesting looking at the documentation for C# fixed-size buffers which
is here:http://msdn2.microsoft.com/en-us/lib...ya(VS.80).aspx

A dynamic (.NET) array carries additional stuff with it like length.
Additionally, since .NET arrays are ref class, only a pointer is stored in
the structure. This is totally different from the layout used by the C++
structure definition you gave.
On Apr 18, 2:01 pm, "Ben Voigt" <r...@nospam.no spamwrote:
"AM" <abhi.me...@gma il.comwrote in message
>news:11******* **************@ o5g2000hsb.goog legroups.com...
Hi,
I have a C++ Dll that has a function that is being exported as
shown below
extern "C" __declspec(dlle xport) validationResul t __stdcall
_validateData(d ouble dataToMat[], int time);
A structure is defined in the header(.h file) as shown below
struct validationResul t
{
int rWaveValid; //validity of the WAVE
int signalStatusArr ay[4]; //validity of each of the channel data -
'causing the problems'
};
I need to call the above method from C# in where i have the following
structure defined
public struct validationResul t
{
public int micDataValid; //validity of the microphone data
magically appeared?
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
channel data
No, that doesn't match. A dynamically resizeable array is not the same
as
an inline array of size 4. Look for the 'fixed' keyword in the C# help.
};
And my function call is as shown
validationResul t res = new validationResul t();
res.signalStatu sArray = new int[4];
res = _validateData(d ataToMat, 2);
When the last line is reached i get an exception that says"Method's
type signature is not PInvoke compatible"
What am I doing wrong.
I know the issue is at the array inside the struct, as when I remove
the array from the C++ struct and the C# struct I get the right
response.
Thanks in Advance.
abhi M

Apr 19 '07 #7

"AM" <ab********@gma il.comwrote in message
news:11******** *************@b 75g2000hsg.goog legroups.com...
In that case what should my C# definition look like for the
corresponding C++ definition mentioned below?

C++ struct
struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
int signalStatusArr ay[4]; //validity of each of the channel
data
};
C# (not compile tested)

unsafe struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
fixed int signalStatusArr ay[4]; //validity of each of the channel
data
};

or

struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
int signalStatusArr ay_0; //validity of each of the channel data
int signalStatusArr ay_1;
int signalStatusArr ay_2;
int signalStatusArr ay_3;
};
>
Thanks

On Apr 19, 10:31 am, "Ben Voigt" <r...@nospam.no spamwrote:
>"AM" <abhi.me...@gma il.comwrote in message

news:11******* *************** @n59g2000hsh.go oglegroups.com. ..
>I guess i did not copy my code correctly.
Here is what my C# struct looks like
public struct validationResul t
{
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
//channel data
};
Are you suggesting that the the error is caused by my array definition
in C# is dynamic (because of the []), while my C++ array is of size 4?

I am suggesting looking at the documentation for C# fixed-size buffers
which
is here:http://msdn2.microsoft.com/en-us/lib...ya(VS.80).aspx

A dynamic (.NET) array carries additional stuff with it like length.
Additionally , since .NET arrays are ref class, only a pointer is stored
in
the structure. This is totally different from the layout used by the C++
structure definition you gave.
On Apr 18, 2:01 pm, "Ben Voigt" <r...@nospam.no spamwrote:
"AM" <abhi.me...@gma il.comwrote in message
>>news:11****** *************** @o5g2000hsb.goo glegroups.com.. .
Hi,
I have a C++ Dll that has a function that is being exported as
shown below
extern "C" __declspec(dlle xport) validationResul t __stdcall
_validateData(d ouble dataToMat[], int time);
A structure is defined in the header(.h file) as shown below
struct validationResul t
{
int rWaveValid; //validity of the WAVE
int signalStatusArr ay[4]; //validity of each of the channel data -
'causing the problems'
};
I need to call the above method from C# in where i have the
following
structure defined
public struct validationResul t
{
public int micDataValid; //validity of the microphone data
>magically appeared?
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
channel data
>No, that doesn't match. A dynamically resizeable array is not the
same
as
an inline array of size 4. Look for the 'fixed' keyword in the C#
help.
};
And my function call is as shown
validationResul t res = new validationResul t();
res.signalStatu sArray = new int[4];
res = _validateData(d ataToMat, 2);
When the last line is reached i get an exception that says"Method's
type signature is not PInvoke compatible"
What am I doing wrong.
I know the issue is at the array inside the struct, as when I remove
the array from the C++ struct and the C# struct I get the right
response.
Thanks in Advance.
abhi M


Apr 19 '07 #8
AM
When I use the struct u suggested
unsafe struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
fixed int signalStatusArr ay[4]; //validity of each of the
channel
data

};
I get the following error.
Unable to find an entry point named '_validateData' in DLL
'CppMatlabWrapp er.dll'.

This error goes away When i remove the array fro both the C++ and the
C# structs. So I think It has something to do with the way my array is
declared in the struct.

Thanks.


On Apr 19, 11:52 am, "Ben Voigt" <r...@nospam.no spamwrote:
"AM" <abhi.me...@gma il.comwrote in message

news:11******** *************@b 75g2000hsg.goog legroups.com...
In that case what should my C# definition look like for the
corresponding C++ definition mentioned below?
C++ struct
struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
int signalStatusArr ay[4]; //validity of each of the channel
data
};

C# (not compile tested)

unsafe struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
fixed int signalStatusArr ay[4]; //validity of each of the channel
data

};

or

struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
int signalStatusArr ay_0; //validity of each of the channel data
int signalStatusArr ay_1;
int signalStatusArr ay_2;
int signalStatusArr ay_3;

};
Thanks
On Apr 19, 10:31 am, "Ben Voigt" <r...@nospam.no spamwrote:
"AM" <abhi.me...@gma il.comwrote in message
>news:11******* *************** @n59g2000hsh.go oglegroups.com. ..
I guess i did not copy my code correctly.
Here is what my C# struct looks like
public struct validationResul t
{
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
//channel data
};
Are you suggesting that the the error is caused by my array definition
in C# is dynamic (because of the []), while my C++ array is of size 4?
I am suggesting looking at the documentation for C# fixed-size buffers
which
is here:http://msdn2.microsoft.com/en-us/lib...ya(VS.80).aspx
A dynamic (.NET) array carries additional stuff with it like length.
Additionally, since .NET arrays are ref class, only a pointer is stored
in
the structure. This is totally different from the layout used by the C++
structure definition you gave.
On Apr 18, 2:01 pm, "Ben Voigt" <r...@nospam.no spamwrote:
"AM" <abhi.me...@gma il.comwrote in message
>news:11******* **************@ o5g2000hsb.goog legroups.com...
Hi,
I have a C++ Dll that has a function that is being exported as
shown below
extern "C" __declspec(dlle xport) validationResul t __stdcall
_validateData(d ouble dataToMat[], int time);
A structure is defined in the header(.h file) as shown below
struct validationResul t
{
int rWaveValid; //validity of the WAVE
int signalStatusArr ay[4]; //validity of each of the channel data -
'causing the problems'
};
I need to call the above method from C# in where i have the
following
structure defined
public struct validationResul t
{
public int micDataValid; //validity of the microphone data
magically appeared?
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
channel data
No, that doesn't match. A dynamically resizeable array is not the
same
as
an inline array of size 4. Look for the 'fixed' keyword in the C#
help.
};
And my function call is as shown
validationResul t res = new validationResul t();
res.signalStatu sArray = new int[4];
res = _validateData(d ataToMat, 2);
When the last line is reached i get an exception that says"Method's
type signature is not PInvoke compatible"
What am I doing wrong.
I know the issue is at the array inside the struct, as when I remove
the array from the C++ struct and the C# struct I get the right
response.
Thanks in Advance.
abhi M

Apr 19 '07 #9
AM
Just so you guys know, I found a solution to the problem at the MSDN
forums. Here is a listing of the code

Code - header file

Header file
//Structure to store the result of the validation operation
struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
int signalStatusArr ay[4]; //validity of each of the channel data -
causing the problems
};

extern "C" __declspec(dlle xport) void __stdcall _validateData(d ouble
dataToMat[], int time, validationResul t *retval);
Code - CPP file

Cpp file
extern "C" __declspec(dlle xport) void __stdcall _validateData(d ouble
dataToMat[], int time, validationResul t *retval)
{

retval->micDataValid = 10;
retval->rWaveValid =20;

retval->signalStatusAr ray[0] =1;
retval->signalStatusAr ray[1] =2;
retval->signalStatusAr ray[2] =3;
retval->signalStatusAr ray[3] =4;
return;
}
Code - C# code

Here is a listing of the C# code
class Program
{
unsafe struct validationResul t
{
int micDataValid;
int rWaveValid;
fixed int signalStatusArr ay[4];
}
static void Main(string[] args)
{
validationResul t res;
_validateData(d ataToMat, 2,out res);

//assume dataToMat is an array with //
data already in it
}
}
----------------------------------

Thanks again.
On Apr 19, 1:41 pm, AM <abhi.me...@gma il.comwrote:
When I use the struct u suggested
unsafe struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
fixed int signalStatusArr ay[4]; //validity of each of the
channel
data

};

I get the following error.
Unable to find an entry point named '_validateData' in DLL
'CppMatlabWrapp er.dll'.

This error goes away When i remove the array fro both the C++ and the
C# structs. So I think It has something to do with the way my array is
declared in the struct.

Thanks.

On Apr 19, 11:52 am, "Ben Voigt" <r...@nospam.no spamwrote:
"AM" <abhi.me...@gma il.comwrote in message
news:11******** *************@b 75g2000hsg.goog legroups.com...
In that case what should my C# definition look like for the
corresponding C++ definition mentioned below?
C++ struct
struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
int signalStatusArr ay[4]; //validity of each of the channel
data
};
C# (not compile tested)
unsafe struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
fixed int signalStatusArr ay[4]; //validity of each of the channel
data
};
or
struct validationResul t
{
int micDataValid; //validity of the microphone data
int rWaveValid; //validity of the r Wave
int signalStatusArr ay_0; //validity of each of the channel data
int signalStatusArr ay_1;
int signalStatusArr ay_2;
int signalStatusArr ay_3;
};
Thanks
On Apr 19, 10:31 am, "Ben Voigt" <r...@nospam.no spamwrote:
>"AM" <abhi.me...@gma il.comwrote in message
>>news:11****** *************** *@n59g2000hsh.g ooglegroups.com ...
>I guess i did not copy my code correctly.
Here is what my C# struct looks like
public struct validationResul t
{
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
//channel data
};
Are you suggesting that the the error is caused by my array definition
in C# is dynamic (because of the []), while my C++ array is of size 4?
>I am suggesting looking at the documentation for C# fixed-size buffers
>which
>is here:http://msdn2.microsoft.com/en-us/lib...ya(VS.80).aspx
>A dynamic (.NET) array carries additional stuff with it like length.
>Additionally , since .NET arrays are ref class, only a pointer is stored
>in
>the structure. This is totally different from the layout used by the C++
>structure definition you gave.
On Apr 18, 2:01 pm, "Ben Voigt" <r...@nospam.no spamwrote:
>"AM" <abhi.me...@gma il.comwrote in message
>>news:11****** *************** @o5g2000hsb.goo glegroups.com.. .
Hi,
I have a C++ Dll that has a function that is being exported as
shown below
extern "C" __declspec(dlle xport) validationResul t __stdcall
_validateData(d ouble dataToMat[], int time);
A structure is defined in the header(.h file) as shown below
struct validationResul t
{
int rWaveValid; //validity of the WAVE
int signalStatusArr ay[4]; //validity of each of the channel data -
'causing the problems'
};
I need to call the above method from C# in where i have the
following
structure defined
public struct validationResul t
{
public int micDataValid; //validity of the microphone data
>magically appeared?
public int rWaveValid; //validity of the r Wave
public int[] signalStatusArr ay; //validity of each of the
channel data
>No, that doesn't match. A dynamically resizeable array is not the
>same
>as
>an inline array of size 4. Look for the 'fixed' keyword in the C#
>help.
};
And my function call is as shown
validationResul t res = new validationResul t();
res.signalStatu sArray = new int[4];
res = _validateData(d ataToMat, 2);
When the last line is reached i get an exception that says"Method's
type signature is not PInvoke compatible"
What am I doing wrong.
I know the issue is at the array inside the struct, as when I remove
the array from the C++ struct and the C# struct I get the right
response.
Thanks in Advance.
abhi M

Apr 23 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
9375
by: Panchal V | last post by:
I want to access a variable length record in C, the format is as follows : +---+---+-----------+ | A | L | D A T A | +---+---+-----------+ A - Some Data (1 BYTE) L - Length the Data that follows (1 BYTE) then actual data
60
2902
by: Mohd Hanafiah Abdullah | last post by:
Is the following code conformat to ANSI C? typedef struct { int a; int b; } doomdata; int main(void) { int x;
36
4407
by: Eric Laberge | last post by:
Hi! I'm working on automatically generated code, and need to assign arrays. memcpy is an obvious solution, but it becomes complicated to use in the context I'm working on, ie.: I could use it but I don't want to. Arrays cannot be assigned in C, but structs can, so I coded the following: #include <stdlib.h>
6
1768
by: Angel | last post by:
I'm exporting (with DllImport) a C-style function with this syntax: int z9indqry (4_PARM *parm); 4_PARM is a structure declared in a proprietary header file that cannot be included in my project (due to C# limits). What would be the other best way to do this? I would like to be able to use the original struct because these structs have over 40 members each and there are several more Structs similar to 4_PARM. Also, they are modified...
5
5303
by: Yourko | last post by:
Hi there! I`me currently trying to write some simple programs in C. For one such program i created globals.h file. In that file i defined a structure of type _client, and a pointer of that type: struct _client{ int fd; // file descriptor struct sockaddr_in sock_name; } * client; Later in that program i do: client = (struct _client *) malloc(sizeof(struct _client));
18
6076
by: Bryan Parkoff | last post by:
I hate using struct / union with dot between two words. How can I use one word instead of two words because I want the source code look reading clear. three variables are shared inside one variable. I manipulate to change 8-bit data before it causes to change 16-bit data and 32-bit data. For example. union {
5
1444
by: pete142 | last post by:
Hi folks -- I have a 4-long array t of of struct Targets. And a table of int * in p. I need to set up the int * entries in p such that each can reference an int in any member of the Targets t array. How to do it?
0
1047
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm exporting a COM interface from my C# application. I want to to export a function that will have an array argument of structs. The struct is like: public struct MyStaruct { int A; int B;
4
5298
by: arnuld | last post by:
I am passing an array of struct to a function to print its value. First I am getting Segfaults and weired values. 2nd, is there any elegant way to do this ? /* Learning how to use an array of struct */ #include <stdio.h>
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.