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. [DLL]: Can I declare a global variable in a DLL?

[DLL]: Can I declare a global variable in a DLL?

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
4 Posts 3 Posters 3 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.
  • B Offline
    B Offline
    Behzad Ebrahimi
    wrote on last edited by
    #1

    Can I declare a global variable in a DLL? My variable is a object of Internal class that NOT exported. Also my global object will use internally. My dll is a "Regular DLL with MFC statically linked". Does it cause a problem?

    D 1 Reply Last reply
    0
    • B Behzad Ebrahimi

      Can I declare a global variable in a DLL? My variable is a object of Internal class that NOT exported. Also my global object will use internally. My dll is a "Regular DLL with MFC statically linked". Does it cause a problem?

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Behzad Ebrahimi wrote: Can I declare a global variable in a DLL? Yes.


      "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

      T 1 Reply Last reply
      0
      • D David Crow

        Behzad Ebrahimi wrote: Can I declare a global variable in a DLL? Yes.


        "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        But How Mr David ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

        D 1 Reply Last reply
        0
        • T ThatsAlok

          But How Mr David ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          The same way you would in an EXE. If the variable is not within the scope of a function, it has file scope, thus it is global. If you want to use the variable in a different file from which it is declared, you'll need to extern it.


          "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

          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