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. C / C++ / MFC
  4. Import a "C" function that returns a struct...

Import a "C" function that returns a struct...

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
2 Posts 2 Posters 1 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.
  • S Offline
    S Offline
    sammyh
    wrote on last edited by
    #1

    I have a .dll with "C" functions that I need to call. One of the functions returns a simple struct(2 doubles) If I try to use DllImport like this: [ DllImport("somedll.dll] SomeStruct1 f1(SomeStruct1 *pS); I get compiler error C3385 "a function that has a DllImport Custom Attribute cannot return an instance of a class" How can I import a function from a DLL that returns a struct??? Thanks a ton, Sam

    R 1 Reply Last reply
    0
    • S sammyh

      I have a .dll with "C" functions that I need to call. One of the functions returns a simple struct(2 doubles) If I try to use DllImport like this: [ DllImport("somedll.dll] SomeStruct1 f1(SomeStruct1 *pS); I get compiler error C3385 "a function that has a DllImport Custom Attribute cannot return an instance of a class" How can I import a function from a DLL that returns a struct??? Thanks a ton, Sam

      R Offline
      R Offline
      Robert A T Kaldy
      wrote on last edited by
      #2

      I have ever thought, that exported functions cannot return a struct or class. Try to pass the return value by pointer: void f1(SomeStruct1 *pS, SomeStruct1 *pReturn); Robert-Antonio "Love without sex is like a fish without antlers"

      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