www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - strange problem, need ideas for debugging...

reply clayasaurus <clayasaurus gmail.com> writes:
I have a weird problem and I have no clue how to debug it. I have tried 
but it has burned my brain out.

A brief about the program : Simple client / server chat model example. I 
am using the C++ raknet lib, so I've created a C wrapper around it.

Here's what I've done...

1) I've created a C wrapper for Raknet.

2) Tested the wrapper in a C++ program using only my C functions. Works 
fine.

3) created extern(C) D functions to link to the C functions, added 
-lstdc++ to the D version.

4) Compile, test, run.

I have 2 versions of the program, the C version and D version.

The D server version can't recieve packets, but the D client version can 
receive packets from the C server and send packets to the C server.

The code is exactly the same for the C and D version, expect the D 
version has extern(C) linkage.

I did try to debug at the library level (raknet), and found that no 
packets were even on the queue for the D server version, but they are 
for the C version, and they are for the D client when 'talking' to the C 
server.

I have been trying but am all out of ideas how to debug this thing. My 
mind can't wander far from the assumption that if the C version works 
and the D version uses the same code, it should work as well.

Thanks

~ Clay

PS. The code is here 
http://svn.dsource.org/projects/warbots/trunk/cinterface/ if you want to 
  take a look
Nov 14 2005
next sibling parent reply John Reimer <John_member pathlink.com> writes:
In article <dlbh2p$26eu$1 digitaldaemon.com>, clayasaurus says...
I have a weird problem and I have no clue how to debug it. I have tried 
but it has burned my brain out.
<snip> Are you working on Linux or Windows? If you are working on Windows, it looks like your rakglue interface is declaring itself extern(C) while your d import code is declaring the rakglue C functions with extern(Windows) linkage. Or maybe I'm not seeing the picture correctly... -JJR
Nov 14 2005
parent clayasaurus <clayasaurus gmail.com> writes:
John Reimer wrote:
 In article <dlbh2p$26eu$1 digitaldaemon.com>, clayasaurus says...
 
I have a weird problem and I have no clue how to debug it. I have tried 
but it has burned my brain out.
<snip> Are you working on Linux or Windows? If you are working on Windows, it looks like your rakglue interface is declaring itself extern(C) while your d import code is declaring the rakglue C functions with extern(Windows) linkage. Or maybe I'm not seeing the picture correctly... -JJR
I'm working on linux but want to make the code x-platform. Can it be fixed up with the following... #ifdef _WIN32 extern "Windows" { #endif #ifdef LINUX extern "C" { #endif } ? Thanks ~ Clay
Nov 14 2005
prev sibling next sibling parent clayasaurus <clayasaurus gmail.com> writes:
I'm not sure if my problem has to do with the Packet structure. I have 
one defined in the C++ version and one defined in the D version. Is 
there any way to extern data structures?

clayasaurus wrote:
 I have a weird problem and I have no clue how to debug it. I have tried 
 but it has burned my brain out.
 
 A brief about the program : Simple client / server chat model example. I 
 am using the C++ raknet lib, so I've created a C wrapper around it.
 
 Here's what I've done...
 
 1) I've created a C wrapper for Raknet.
 
 2) Tested the wrapper in a C++ program using only my C functions. Works 
 fine.
 
 3) created extern(C) D functions to link to the C functions, added 
 -lstdc++ to the D version.
 
 4) Compile, test, run.
 
 I have 2 versions of the program, the C version and D version.
 
 The D server version can't recieve packets, but the D client version can 
 receive packets from the C server and send packets to the C server.
 
 The code is exactly the same for the C and D version, expect the D 
 version has extern(C) linkage.
 
 I did try to debug at the library level (raknet), and found that no 
 packets were even on the queue for the D server version, but they are 
 for the C version, and they are for the D client when 'talking' to the C 
 server.
 
 I have been trying but am all out of ideas how to debug this thing. My 
 mind can't wander far from the assumption that if the C version works 
 and the D version uses the same code, it should work as well.
 
 Thanks
 
 ~ Clay
 
 PS. The code is here 
 http://svn.dsource.org/projects/warbots/trunk/cinterface/ if you want to 
  take a look
Nov 14 2005
prev sibling parent reply clayasaurus <clayasaurus gmail.com> writes:
I tried to fix it by wrapping the packet stuff, but the same exact 
problem exists.

It is like the library isn't working when I link it to D, maybe 
something didn't get initialized. Maybe -lstdc++ borks the code. I don't 
know.

clayasaurus wrote:
 I have a weird problem and I have no clue how to debug it. I have tried 
 but it has burned my brain out.
 
 A brief about the program : Simple client / server chat model example. I 
 am using the C++ raknet lib, so I've created a C wrapper around it.
 
 Here's what I've done...
 
 1) I've created a C wrapper for Raknet.
 
 2) Tested the wrapper in a C++ program using only my C functions. Works 
 fine.
 
 3) created extern(C) D functions to link to the C functions, added 
 -lstdc++ to the D version.
 
 4) Compile, test, run.
 
 I have 2 versions of the program, the C version and D version.
 
 The D server version can't recieve packets, but the D client version can 
 receive packets from the C server and send packets to the C server.
 
 The code is exactly the same for the C and D version, expect the D 
 version has extern(C) linkage.
 
 I did try to debug at the library level (raknet), and found that no 
 packets were even on the queue for the D server version, but they are 
 for the C version, and they are for the D client when 'talking' to the C 
 server.
 
 I have been trying but am all out of ideas how to debug this thing. My 
 mind can't wander far from the assumption that if the C version works 
 and the D version uses the same code, it should work as well.
 
 Thanks
 
 ~ Clay
 
 PS. The code is here 
 http://svn.dsource.org/projects/warbots/trunk/cinterface/ if you want to 
  take a look
Nov 14 2005
parent reply clayasaurus <clayasaurus gmail.com> writes:
In an act of desparation I wrapped the whole entire thing in 1 C 
function. Suprisingly, it worked. Now I can debug I think.

clayasaurus wrote:
 I tried to fix it by wrapping the packet stuff, but the same exact 
 problem exists.
 
 It is like the library isn't working when I link it to D, maybe 
 something didn't get initialized. Maybe -lstdc++ borks the code. I don't 
 know.
 
 clayasaurus wrote:
 
 I have a weird problem and I have no clue how to debug it. I have 
 tried but it has burned my brain out.

 A brief about the program : Simple client / server chat model example. 
 I am using the C++ raknet lib, so I've created a C wrapper around it.

 Here's what I've done...

 1) I've created a C wrapper for Raknet.

 2) Tested the wrapper in a C++ program using only my C functions. 
 Works fine.

 3) created extern(C) D functions to link to the C functions, added 
 -lstdc++ to the D version.

 4) Compile, test, run.

 I have 2 versions of the program, the C version and D version.

 The D server version can't recieve packets, but the D client version 
 can receive packets from the C server and send packets to the C server.

 The code is exactly the same for the C and D version, expect the D 
 version has extern(C) linkage.

 I did try to debug at the library level (raknet), and found that no 
 packets were even on the queue for the D server version, but they are 
 for the C version, and they are for the D client when 'talking' to the 
 C server.

 I have been trying but am all out of ideas how to debug this thing. My 
 mind can't wander far from the assumption that if the C version works 
 and the D version uses the same code, it should work as well.

 Thanks

 ~ Clay

 PS. The code is here 
 http://svn.dsource.org/projects/warbots/trunk/cinterface/ if you want 
 to  take a look
Nov 14 2005
parent clayasaurus <clayasaurus gmail.com> writes:
Fixed plus bug report.

clayasaurus wrote:
 In an act of desparation I wrapped the whole entire thing in 1 C 
 function. Suprisingly, it worked. Now I can debug I think.
 
 clayasaurus wrote:
 
 I tried to fix it by wrapping the packet stuff, but the same exact 
 problem exists.

 It is like the library isn't working when I link it to D, maybe 
 something didn't get initialized. Maybe -lstdc++ borks the code. I 
 don't know.

 clayasaurus wrote:

 I have a weird problem and I have no clue how to debug it. I have 
 tried but it has burned my brain out.

 A brief about the program : Simple client / server chat model 
 example. I am using the C++ raknet lib, so I've created a C wrapper 
 around it.

 Here's what I've done...

 1) I've created a C wrapper for Raknet.

 2) Tested the wrapper in a C++ program using only my C functions. 
 Works fine.

 3) created extern(C) D functions to link to the C functions, added 
 -lstdc++ to the D version.

 4) Compile, test, run.

 I have 2 versions of the program, the C version and D version.

 The D server version can't recieve packets, but the D client version 
 can receive packets from the C server and send packets to the C server.

 The code is exactly the same for the C and D version, expect the D 
 version has extern(C) linkage.

 I did try to debug at the library level (raknet), and found that no 
 packets were even on the queue for the D server version, but they are 
 for the C version, and they are for the D client when 'talking' to 
 the C server.

 I have been trying but am all out of ideas how to debug this thing. 
 My mind can't wander far from the assumption that if the C version 
 works and the D version uses the same code, it should work as well.

 Thanks

 ~ Clay

 PS. The code is here 
 http://svn.dsource.org/projects/warbots/trunk/cinterface/ if you want 
 to  take a look
Nov 15 2005