Categories
Looking glass
Navigate/Search

/clr:safe Managed C++ and XNA 360 are good

Enough for this night, I’m pretty much certain now the /clr:safe Managed C++ is always valid XNA 360 code.

I’ve so far tried interior_ptr, arrays, virtual, hierachy, stack based object (which I was sure wouldn’t work but did). So far all code that I’ved compiled under /clr:safe has worked on the 360.

Still more tests to do (STL.CLR templates, generics, varargs stuff) and then I’ll produce a guide and an example project.

Of course /clr:safe code is fairly different from normal C++ code, so its easy to argue why bother porting code from native C++ to /clr:safe code why not just port to C#. I’m betting that I’ll be able to port to C++ /clr:safe faster than C# because things like free functions simply don’t exist in C# but I guess we shall see.

I’m tempted to try making a port of Lua to /clr:safe to see a)how hard it is and b)if possible but thats a bit further down the line.

2 Responses to “/clr:safe Managed C++ and XNA 360 are good”

  1. Pedro Urbina Says:

    Hello, I’m force to generate a game in Cpp but since I’m familiar with XNA, I wanted to follow your idea. I don’t know anything about /clr:safe or managed code. Could you give a couple hints?

    Thank you

    Pedro

  2. Deano Says:

    Hi Pedro,
    Fundementally you have to write using a modified version of C++, that MS call C++/CLI.

    Using that you can then write classes that can be accessed easily via XNA, you have to tell it they a managed classes and allocate them via gcnew rather than new.

    I haven’t dealt much deeper than my initial tests and have a mixed C++/C# content pipeline in XNua.

    I do have a good book on it tho, I dig out a reference when I’m back at home.

    Bye,
    Deano

Leave a Reply