Skip to main content
gamedev.net
🔒 Locked

Mixing C# and C++/C in the same project

Started by Telamon 3 replies 19.8k views
Original Post
Telamon
Telamon
Hello, I took a class last spring on C# programming and the professor made the claim that it was very easy to mix C# with other .Net languages like C++. I was interested in how this works and am wondering if anyone knows of any good tutorial/examples of it. I have some experience in writing DLLs, so I know how to mix languages that way, but my professor made it seem like it could be done at a more transparent level in .Net. I know that .Net languages compile to MSIL, and I was wondering if that fact made clever language thunking possible. Basically, what I''m most interested in is mixing C# with unmanaged C/C++ to optimize the inner loops of some pixel-manipulation code in the game I''m working on. I''m looking for a solution that''s as easy and painless as adding inline assembly to C code.
Maega
Maega
I have never heard of this being done.

Ive heard of managed C++ and unmanaged C++ being used together, but C# was never mentioned in conjuction with unmanaged C++ outside of the context of DLLs.

I did find an article on CodeProject about using "legacy" C++ dlls in C# projects.

I will continue to look around.

link:

http://www.codeproject.com/useritems/interop.asp


Telamon
Telamon
Well, I''m developing a game for a class project using C#. It''s actually a Tetris Attack clone with lots of crazy seizure-inducing 3D eye candy. I''m using C# for it''s RAD-ness. I got the basic game logic implemented in a couple of hours and I''ve never had a bug in C# that took longer than two minutes to fix. It''s actually a pretty sweet programming tool. I''m not sure what the difference in speed between C# code and C/C++ code is my assumption in asking about mixing languages was the C was faster for per-pixel image and texture manipulation. Maybe this isn''t the case.
JonStelly
JonStelly
You can''t mix C++ and C# in the same Visual Studio project, but you can make a class library in one language, then reference that project / class library in a different project using the other language.

Personally, for something like a Tetris clone I wouldn''t worry about C++. You should be able to write something "fast enough"(tm) using just C#.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.