Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. __gc* equivalent in VC++ 2005

__gc* equivalent in VC++ 2005

Scheduled Pinned Locked Moved Managed C++/CLI
c++announcement
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    madhusri
    wrote on last edited by
    #1

    I understand that the equivalent for __gc in VC++ 2005 is ref keyword. Similarly can anyone update me on the equivalent for __gc* in VC++ 2005. Thanks in advance Thanks and Regards Madhu

    N 1 Reply Last reply
    0
    • M madhusri

      I understand that the equivalent for __gc in VC++ 2005 is ref keyword. Similarly can anyone update me on the equivalent for __gc* in VC++ 2005. Thanks in advance Thanks and Regards Madhu

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      madhusri wrote:

      I understand that the equivalent for __gc in VC++ 2005 is ref keyword. Similarly can anyone update me on the equivalent for __gc* in VC++ 2005. Thanks in advance

      I answered this in the MS forum too. But since you've posted here, and since others may have the same question in future, here's the answer once again :- A^ a = gcnew A(); The A^ is a handle to the managed object A (similar to __gc* in MC++) Regards, Nish

      My blog : Nish’s thoughts on MFC, C++/CLI and .NET

      M 1 Reply Last reply
      0
      • N Nish Nishant

        madhusri wrote:

        I understand that the equivalent for __gc in VC++ 2005 is ref keyword. Similarly can anyone update me on the equivalent for __gc* in VC++ 2005. Thanks in advance

        I answered this in the MS forum too. But since you've posted here, and since others may have the same question in future, here's the answer once again :- A^ a = gcnew A(); The A^ is a handle to the managed object A (similar to __gc* in MC++) Regards, Nish

        My blog : Nish’s thoughts on MFC, C++/CLI and .NET

        M Offline
        M Offline
        madhusri
        wrote on last edited by
        #3

        Sivakumar, Thanks for your response. I had actually tried with this option earlier. But then i did not get the problem solved. May be i'll try explaning you what i actually need with this code segment so that you can help me out. The objective is i have to access a dll through C# code. The dll is created from VC++ code. In the C# code i need to pass the address as the function argument. In VS 2003 i could achieve it through the following C++ code segment: public:void GetIntReturn(int __gc* ivalue) { *ivalue=10; } Here's the C# code segment calling the corresponding function. public int GetValueFromC++() { int i =0; GetIntReturn(ref i) return i; } This work fine and this is what i want. But now i got to do the same using VS2005. As you said earlier i tried replacing __gc* with ^. But when invoking this function in C# it asks me for value type and not reference type. Can you help me out with this please. Thanks and Regards Madhu

        N 1 Reply Last reply
        0
        • M madhusri

          Sivakumar, Thanks for your response. I had actually tried with this option earlier. But then i did not get the problem solved. May be i'll try explaning you what i actually need with this code segment so that you can help me out. The objective is i have to access a dll through C# code. The dll is created from VC++ code. In the C# code i need to pass the address as the function argument. In VS 2003 i could achieve it through the following C++ code segment: public:void GetIntReturn(int __gc* ivalue) { *ivalue=10; } Here's the C# code segment calling the corresponding function. public int GetValueFromC++() { int i =0; GetIntReturn(ref i) return i; } This work fine and this is what i want. But now i got to do the same using VS2005. As you said earlier i tried replacing __gc* with ^. But when invoking this function in C# it asks me for value type and not reference type. Can you help me out with this please. Thanks and Regards Madhu

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          Ah ok, the C++/CLI equivalent for that is

          void GetIntReturn(int% ivalue)
          {
          ivalue = 10;
          }

          Regards, Nish

          My blog : Nish’s thoughts on MFC, C++/CLI and .NET

          M S 2 Replies Last reply
          0
          • N Nish Nishant

            Ah ok, the C++/CLI equivalent for that is

            void GetIntReturn(int% ivalue)
            {
            ivalue = 10;
            }

            Regards, Nish

            My blog : Nish’s thoughts on MFC, C++/CLI and .NET

            M Offline
            M Offline
            madhusri
            wrote on last edited by
            #5

            Sivakumar, Thanks for your response. This worked out well for me. Thanks and Regards Madhu

            1 Reply Last reply
            0
            • N Nish Nishant

              Ah ok, the C++/CLI equivalent for that is

              void GetIntReturn(int% ivalue)
              {
              ivalue = 10;
              }

              Regards, Nish

              My blog : Nish’s thoughts on MFC, C++/CLI and .NET

              S Offline
              S Offline
              Sriinii
              wrote on last edited by
              #6

              Thanks we got an idea. but this doesn't work on class ,string and structures how can this be used for those data types Regards Srini

              N G 2 Replies Last reply
              0
              • S Sriinii

                Thanks we got an idea. but this doesn't work on class ,string and structures how can this be used for those data types Regards Srini

                N Offline
                N Offline
                Nish Nishant
                wrote on last edited by
                #7

                Sriinii wrote:

                Thanks we got an idea. but this doesn't work on class ,string and structures

                In what way does it not work? Regards, Nish

                My blog : Nish’s thoughts on MFC, C++/CLI and .NET

                1 Reply Last reply
                0
                • S Sriinii

                  Thanks we got an idea. but this doesn't work on class ,string and structures how can this be used for those data types Regards Srini

                  G Offline
                  G Offline
                  George L Jackson
                  wrote on last edited by
                  #8

                  You have to do the following: void GetStringReturn(String^% stringValue) {      stringValue = "10"; } -- modified at 14:59 Friday 3rd February, 2006

                  E 1 Reply Last reply
                  0
                  • G George L Jackson

                    You have to do the following: void GetStringReturn(String^% stringValue) {      stringValue = "10"; } -- modified at 14:59 Friday 3rd February, 2006

                    E Offline
                    E Offline
                    engsrini
                    wrote on last edited by
                    #9

                    This is gr8 it is working for me. Thanks George, Nishant. Thank u very much Regards, Srini:-O

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups