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. linking static variables

linking static variables

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
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.
  • V Offline
    V Offline
    vilmer
    wrote on last edited by
    #1

    Hi, I'm trying to use threads in my app and I should use static variables shared between all threads. Linking the app generates a link error: unresolved symbol static etc... How can I avoid it? Thanks Vilmer

    V 1 Reply Last reply
    0
    • V vilmer

      Hi, I'm trying to use threads in my app and I should use static variables shared between all threads. Linking the app generates a link error: unresolved symbol static etc... How can I avoid it? Thanks Vilmer

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      How are you declaring the static global variables? Kuphryn

      V 1 Reply Last reply
      0
      • V valikac

        How are you declaring the static global variables? Kuphryn

        V Offline
        V Offline
        vilmer
        wrote on last edited by
        #3

        I've just declared the veriables as static, but in MyDialog class (where MyDialog is the main dialog class of my app)

        M V 2 Replies Last reply
        0
        • V vilmer

          I've just declared the veriables as static, but in MyDialog class (where MyDialog is the main dialog class of my app)

          M Offline
          M Offline
          Mike Beckerleg
          wrote on last edited by
          #4

          If in the .h file for your class you have class MyClass { static int mStatic; } Then in the .cpp you will need the following int MyClass::mStatic = 123; Mike

          1 Reply Last reply
          0
          • V vilmer

            I've just declared the veriables as static, but in MyDialog class (where MyDialog is the main dialog class of my app)

            V Offline
            V Offline
            valikac
            wrote on last edited by
            #5

            One solution is to declare the global variable in stdafx.h. Kuphryn

            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