CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2006
    Posts
    1

    [RESOLVED] Mixed mode future, enumerations, static variables

    Hello MVP's,

    Question 1)
    Does Microsoft plan to continue support for a mixture of managed and unmanaged c++ code in a single c++ project? If so, how long do they plan on supporting this option?

    Question 2)
    When projects are a mixture of unmanaged code written in c++ and then wrapped with managed c++ so a .NET GUI can be used, any enumerations defined in the unmanaged area are necessary in the managed area. So they need to be duplicated in the managed wrapper. Is there a simple way to do this without the error prone cut and paste from the unmanaged layer to the managed layer. It's not a big deal for a single enumeration, but this is a hassle for large software systems that contain enumerations at both the unmanaged and managed levels, and of course that is what I'm working on

    Question 3)
    In Visual Studio 2003 I have had problems with global static const doubles.

    A simple example is the following...
    static const double frequency = 30.0;
    static const double period = 1.0 / 30.0;

    After stopping at a break point, the value of the variable period is 0.0 when is should be ~0.03333. What is going on here? The scenario is a c# GUI communicating with a mixed mode C++ DLL. The breakpoint is set in the managed dll and the static const double variable is defined in the managed DLL. The managed dll is made up of a managed c++ project and a static c++ library project that is linked in. When a simple unmanaged c++ client is written to link with just the static c++ library from the managed DLL, period appears as 0.0333333 instead of 0.0. This only appears to be a problem when the fully managed DLL is built and used by a managed client.

    Thank you for your time and patience!

    -Lars

  2. #2
    Join Date
    Jun 2006
    Posts
    17

    Re: Mixed mode future, enumerations, static variables

    1) We support mixing managed and native C++ in a single project (heck, we support the mix in a single file!) today in Visual C++ 2005 with the "/clr" compiler option, and we plan to continue supporting this functionality as far into the future as we can predict today.

    2) Enumerations are very different in the managed world (where they are syntactically more like classes) than the standard C++ world (where they are syntactically more like constants). I don't know of an automatic way to handle the conversion between the two, although I could think of some ways to prevent human error in manually writing wrappers... for example, you could declare all of your enums in standard C++ first and then write a perl script or small C++ program that automatically generates managed code versions as well as conversion functions for you.

    3) I'm unclear as to whether you're talking about a debugger problem or a floating point calculation problem here. Are you saying the program works at run time but the debugger value is not correct, or is it not correct at runtime also?


    Thanks,

    Steve Teixeira
    Group Program Manager
    Visual C++
    Last edited by steixeira; June 19th, 2006 at 07:11 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured