CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Managed C++ and C++/CLI
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Managed C++ and C++/CLI Discuss Managed C++ and .NET-specific questions related to C++.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old July 11th, 2005, 06:55 PM
    mchow2469 mchow2469 is offline
    Member
     
    Join Date: Jun 2005
    Location: Milpitas, CA
    Posts: 42
    mchow2469 is an unknown quantity at this point (<10)
    Talking Passing __gc[] into a function help!!

    Hi,

    I currently need to pass an array "float __gc[]" into a built in function which takes in an array of type void*.

    The compiler isn't liking it and complains:
    testWave.h(113): error C2664: 'FileToArray' : cannot convert parameter 2 from 'float __gc[]' to 'void *'

    Do you guys know a way to get managed and unmanged code to agree?
    Thanks!
    Reply With Quote
      #2    
    Old July 12th, 2005, 06:20 AM
    NoHero's Avatar
    NoHero NoHero is offline
    Moderator
     
    Join Date: Mar 2004
    Location: (Upper-) Austria
    Posts: 2,899
    NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)
    Re: Passing __gc[] into a function help!!

    Passing a managed pointer to an unmanaged is not possible. You need to convert your managed array of floats back to an unmanaged array of floats first, before passing it to the unmanaged function.
    __________________
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!
    Reply With Quote
      #3    
    Old July 12th, 2005, 11:16 AM
    mchow2469 mchow2469 is offline
    Member
     
    Join Date: Jun 2005
    Location: Milpitas, CA
    Posts: 42
    mchow2469 is an unknown quantity at this point (<10)
    Re: Passing __gc[] into a function help!!

    Ok Thanks!

    How would I convert the __gc[] array to a regular array without the garbage collector?
    Reply With Quote
      #4    
    Old July 12th, 2005, 12:04 PM
    NoHero's Avatar
    NoHero NoHero is offline
    Moderator
     
    Join Date: Mar 2004
    Location: (Upper-) Austria
    Posts: 2,899
    NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)
    Re: Passing __gc[] into a function help!!

    Simply create an array with equal size just for the unmanaged counterpart and copy value for value into the unmanaged. Notice: use __nogc new to allocate an unmanaged peace of memory. And be sure to delete it after it has been used.
    __________________
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Managed C++ and C++/CLI


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:51 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009