Try disabling the managed code option on the C++ file which is native. Just right click on the file in solution explorer, go to properties and you should be able to change the option in there.

However I am still a bit confused that you're experiencing problems : there shouldn't be anything wrong with your code as far as I can tell.

You are using the IDE aren't you ? This takes care of all of this sort of thing for you.

Darwen.