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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Error LNK2005 ( extern variable)

Error LNK2005 ( extern variable)

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
3 Posts 2 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.
  • A Offline
    A Offline
    Arif Liminto
    wrote on last edited by
    #1

    Hi ,I am new in mfc and c++, and currently I have got problem with this kind of error basically , i have to file get.cpp and send.cpp and i want to share variable across that files and i thought we can use keyword "extern" so here is my code in send.h int g_iEnabled class csend { ...... } in get.h extern int g_iEnabled class cget { .... } is that the rightway to share variable across multiple files thanks for your help bye :-D

    _ 1 Reply Last reply
    0
    • A Arif Liminto

      Hi ,I am new in mfc and c++, and currently I have got problem with this kind of error basically , i have to file get.cpp and send.cpp and i want to share variable across that files and i thought we can use keyword "extern" so here is my code in send.h int g_iEnabled class csend { ...... } in get.h extern int g_iEnabled class cget { .... } is that the rightway to share variable across multiple files thanks for your help bye :-D

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Put the int g_iEnabled declaration in the .cpp file.

      «_Superman_»

      A 1 Reply Last reply
      0
      • _ _Superman_

        Put the int g_iEnabled declaration in the .cpp file.

        «_Superman_»

        A Offline
        A Offline
        Arif Liminto
        wrote on last edited by
        #3

        Hi thanks men for the solution, it works perfectly

        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