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. char* as return type in dll

char* as return type in dll

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 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.
  • _ Offline
    _ Offline
    _8086
    wrote on last edited by
    #1

    char as return type works fine, extern "C" char _declspec(dllimport) Test(); _declspec(dllexport) char Test() { return 't'; } But why char* doesn't work here as the return type? extern "C" char* _declspec(dllimport) Test(); _declspec(dllexport) char* Test() { return "Test From DLL"; }

    ---------------------------- 286? WOWW!:-O

    S 1 Reply Last reply
    0
    • _ _8086

      char as return type works fine, extern "C" char _declspec(dllimport) Test(); _declspec(dllexport) char Test() { return 't'; } But why char* doesn't work here as the return type? extern "C" char* _declspec(dllimport) Test(); _declspec(dllexport) char* Test() { return "Test From DLL"; }

      ---------------------------- 286? WOWW!:-O

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      _8086 wrote:

      But why char* doesn't work here as the return type?

      Can you define what you mean by 'doesn't work'?

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      _ 2 Replies Last reply
      0
      • S Stuart Dootson

        _8086 wrote:

        But why char* doesn't work here as the return type?

        Can you define what you mean by 'doesn't work'?

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        _ Offline
        _ Offline
        _8086
        wrote on last edited by
        #3

        error C2059: syntax error : '__declspec(dllimport)'

        ---------------------------- 286? WOWW!:-O

        1 Reply Last reply
        0
        • S Stuart Dootson

          _8086 wrote:

          But why char* doesn't work here as the return type?

          Can you define what you mean by 'doesn't work'?

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

          _ Offline
          _ Offline
          _8086
          wrote on last edited by
          #4

          By the way, I'm keeping extern "C" char* _declspec(dllimport) Test(); in a .h file.

          ---------------------------- 286? WOWW!:-O

          0 1 Reply Last reply
          0
          • _ _8086

            By the way, I'm keeping extern "C" char* _declspec(dllimport) Test(); in a .h file.

            ---------------------------- 286? WOWW!:-O

            0 Offline
            0 Offline
            0x3c0
            wrote on last edited by
            #5

            This is just a hunch, but the declaration looks a little off. Try putting char* after the _declspec, instead of before it; that worked for me

            Between the idea And the reality Between the motion And the act Falls the Shadow

            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