473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

MC++... unable to compile my code correctly :-(

I m new to MC++ and interoperability and I try to find a bug since a long
time without succes, maybe you can help me ?

(I have a sample project if you want, you can contact me at
cd*****@hotmail.com too)

I describe the problem:

I have 2 MS VC2003 projects... and have difference between both. The first
one is a MC++ project I have create, the second is the original C++ library
(that works fine!)

1 - Here is my managed class :
----------------------------------------------
public __gc class UFOzSocket
{
private:
addrinfo _hints;
public:
UFOzSocket(AddressFamily addressFamily, SocketType socketType);
~UFOzSocket();
void Connect(EndPoint * remoteEP);
protected:
UFOzSocket();
private:
UDTSOCKET _internalSocket;
};

During debugging, when I see this structure, it is like this :

Structure in the first application, see by the debugger (Bad fields order):
-----------------------------------------------------------------------------
- _hints : addrinfo
+ ai_addr : 0x00000000 sockaddr*
+ ai_addrlen : 0 unsigned __int32
+ ai_canonname : 0x00000000 char*
+ ai_family :2 __int32
+ ai_flags :1 __int32
+ ai_next : 0x00000000 addrinfo*
+ ai_protocol : 0 __int32
+ ai_socktype : 1 __int32

Structure in the second application, see by the debugger (Good fields order):
----------------------------------------------------------------------------------
- hints {ai_flags=1 ai_family=2 ai_socktype=1 ...} addrinfo
+ ai_flags : 1 int
+ ai_family : 2 int
+ ai_socktype : 1 int
+ ai_protocol : 0 int
+ ai_addrlen : 0 unsigned int
+ ai_canonname : 0x00000000 <Bad Ptr> char *
+ ai_addr : 0x00000000 {sa_family=??? sa_data=0x00000002 <Bad
Ptr> } sockaddr *
+ ai_next : 0x00000000 {ai_flags=??? ai_family=???
ai_socktype=??? ...} addrinfo *

So, how can I change this to force the first application to have the same
behavior ?

Thanks for your help

Chris
Mar 27 '06 #1
5 1016
Hi Chris!
UDTSOCKET _internalSocket;

During debugging, when I see this structure, it is like this :


How is this structure defined?
You must use the "StructLayoutAttribute" attribute if you want to deal
with "offsets"...
See:
http://msdn.microsoft.com/library/en...ClassTopic.asp

Greetings
Jochen
Mar 27 '06 #2
Thanks

but the problem is on the structure "addrinfo" defined like this :

typedef struct addrinfo
{
int ai_flags; // AI_PASSIVE, AI_CANONNAME,
AI_NUMERICHOST
int ai_family; // PF_xxx
int ai_socktype; // SOCK_xxx
int ai_protocol; // 0 or IPPROTO_xxx for IPv4 and IPv6
size_t ai_addrlen; // Length of ai_addr
char * ai_canonname; // Canonical name for nodename
struct sockaddr * ai_addr; // Binary address
struct addrinfo * ai_next; // Next structure in linked list
}
ADDRINFOA, *PADDRINFOA;

in the file "ws2tcpip.h"

and not in one of my files :-( ... so I cannot change it !

It is the problem !!
Mar 27 '06 #3
Jochen...

I have a sample project... in a ZIP that is ready, if you want to see to
problem...

It is simple, surely for you (I have see your web site about interop)... but
for me, it sounds complex ( I work on it since 2 week without success :-( )

Thanks for your help

"Jochen Kalmbach [MVP]" wrote:
Hi Chris!
UDTSOCKET _internalSocket;

During debugging, when I see this structure, it is like this :


How is this structure defined?
You must use the "StructLayoutAttribute" attribute if you want to deal
with "offsets"...
See:
http://msdn.microsoft.com/library/en...ClassTopic.asp

Greetings
Jochen

Mar 27 '06 #4
Hi Chris!
I have a sample project... in a ZIP that is ready, if you want to see to
problem...


You can mail it to me:

jochen addddd kalmbachnet dottttt de

Greetings
Jochen
Mar 27 '06 #5
Hi Jochen,

I have send you an email

Thanks for your help
Mar 27 '06 #6

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

Similar topics

0
by: Daniel Lidström | last post by:
Hi, I've been trying a long time now to generate some XML using MC++ and XmlSerializer. I have a piece of C# code that produces exactly what I want, but I simply can't get the MC++ code to write...
1
by: Philip | last post by:
I am trying to return a string from a mc++ method back to an invoking C# module. In the invoking C# module I have the string defined as.... String strString;.... in mc++ the method definition is...
2
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a...
0
by: Eric Twietmeyer | last post by:
Hello, Am I mistaken in thinking that if I have a mc++ dll that I should be able to link against it (so long as it has exported symbols via declspec(dllexport)) in an unmanaged application? I...
0
by: Maxwell | last post by:
Hello, I recently completed a MC++ (VS2003) DLL that wraps a non MFC C++ DLL and need to use it in a MC++ Console Application (no forms/guis of any kind just output to console). Trouble is...
3
by: Shawn B. | last post by:
Greetings, I'm trying to create a Managed C++ library that extends the console features beyond System::Console capabilities. I chose MC++ over C++/CLI because I need it to work on the 1.1...
0
by: ufnuceda | last post by:
Hello everyone, I was wondering if any of you have some experience with the boost library. I am having trouble compiling code with it. Since boost is being used a lot these days I thought some...
8
by: WebSnozz | last post by:
I have an application written in C that does a lot of low level stuff. It does a lot of things like casting from void*'s. I want to create a new GUI for it in either C# or MC++, but reuse the...
1
by: paulcybulski | last post by:
I am trying to create a function where if a user double clicks on a particular mc the mc will reset itself to its original zoom and position...however, I cannot get this feature to work...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...
0
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...

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.