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. Managed and Unmanaged structures

Managed and Unmanaged structures

Scheduled Pinned Locked Moved Managed C++/CLI
helpc++questionlounge
6 Posts 2 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.
  • J Offline
    J Offline
    jarl
    wrote on last edited by
    #1

    I think this overlaps somewhat with the general problems people seem to have with mixing C++ and MC++ code when pointers enters the equation, but anyways, here it the problem: I have an unmanaged struct like so: __nogc struct foo { int data_; }; and then I have a managed struct like so: __gc struct bar { foo is_this_unmanaged_still; }; And...this doesn't compile. : error C3633: cannot define 'is_this_unmanaged_still' as a member of managed 'bar' I don't have my MC++ books yet, so excuse me if this is a bit of a naff question, but I am in the middle of porting some C++ code to be cross-C++/MC++ compatible and these little diddlers are causing me some immediate headaches...;P cheers -=jarl=-

    J 1 Reply Last reply
    0
    • J jarl

      I think this overlaps somewhat with the general problems people seem to have with mixing C++ and MC++ code when pointers enters the equation, but anyways, here it the problem: I have an unmanaged struct like so: __nogc struct foo { int data_; }; and then I have a managed struct like so: __gc struct bar { foo is_this_unmanaged_still; }; And...this doesn't compile. : error C3633: cannot define 'is_this_unmanaged_still' as a member of managed 'bar' I don't have my MC++ books yet, so excuse me if this is a bit of a naff question, but I am in the middle of porting some C++ code to be cross-C++/MC++ compatible and these little diddlers are causing me some immediate headaches...;P cheers -=jarl=-

      J Offline
      J Offline
      jarl
      wrote on last edited by
      #2

      ..sorry, the question wasn't really in there now, was it...? my question is: why doesn't this work ? ...I have feeling I might have asked a completely stupid question here.... ;P -=jarl=-

      P 1 Reply Last reply
      0
      • J jarl

        ..sorry, the question wasn't really in there now, was it...? my question is: why doesn't this work ? ...I have feeling I might have asked a completely stupid question here.... ;P -=jarl=-

        P Offline
        P Offline
        Paul Selormey
        wrote on last edited by
        #3

        Hello there, The following compiles...

        #include "stdafx.h"

        #using #include using namespace System;

        __nogc struct StdHello
        {
        int nSomething;
        };

        __value struct MCHello
        {
        StdHello member;
        };

        // This is the entry point for this application
        int _tmain(void)
        {
        // TODO: Please replace the sample code below with your own.
        Console::WriteLine(S"Hello World");

        MCHello hello;
        hello.member.nSomething = 2003227;
        
        Console::WriteLine(\_\_box(hello.member.nSomething));
        
        return 0;
        

        }

        I hope you see the difference ;P It pays to buy a book, if not read the MC++ reference it is quite informative. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.

        J 1 Reply Last reply
        0
        • P Paul Selormey

          Hello there, The following compiles...

          #include "stdafx.h"

          #using #include using namespace System;

          __nogc struct StdHello
          {
          int nSomething;
          };

          __value struct MCHello
          {
          StdHello member;
          };

          // This is the entry point for this application
          int _tmain(void)
          {
          // TODO: Please replace the sample code below with your own.
          Console::WriteLine(S"Hello World");

          MCHello hello;
          hello.member.nSomething = 2003227;
          
          Console::WriteLine(\_\_box(hello.member.nSomething));
          
          return 0;
          

          }

          I hope you see the difference ;P It pays to buy a book, if not read the MC++ reference it is quite informative. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.

          J Offline
          J Offline
          jarl
          wrote on last edited by
          #4

          Ok, yes, I am waiting impatiently for my books, so in the meantime I'm abusing the nice people at CodeProj... ;) Ok, you've answered my question; You can only contain a managed structure in another managed structure. cheers -=jarl=-

          P 1 Reply Last reply
          0
          • J jarl

            Ok, yes, I am waiting impatiently for my books, so in the meantime I'm abusing the nice people at CodeProj... ;) Ok, you've answered my question; You can only contain a managed structure in another managed structure. cheers -=jarl=-

            P Offline
            P Offline
            Paul Selormey
            wrote on last edited by
            #5

            -=jarl=- wrote: Ok, you've answered my question; You can only contain a managed structure in another managed structure. No you did not get it, __nogc means StdHello is unmanaged. __value means MCHello is a managed structure, better called value. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.

            J 1 Reply Last reply
            0
            • P Paul Selormey

              -=jarl=- wrote: Ok, you've answered my question; You can only contain a managed structure in another managed structure. No you did not get it, __nogc means StdHello is unmanaged. __value means MCHello is a managed structure, better called value. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.

              J Offline
              J Offline
              jarl
              wrote on last edited by
              #6

              ...ah....I see...;P -=jarl=-

              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