Results 1 to 2 of 2

Thread: Global Variables In Libraries

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2002
    Posts
    5

    Global Variables In Libraries

    I have a project in which a variable is defined in a static library as "extern SCREEN g_Screen;" (where SCREEN is "enum SCREEN {FULL,WINDOWED};"). The library is included in a dynamic library that uses it and, through inclusion of the dynamic library header, in the test application. For some reason when I set g_Screen in the application the library doesn't see the change (and vice versa).

    Am I missing something? I read something somewhere about hooks but I wasn't too sure that it was what I needed. I very much need the library and application to be able to control/read the same instance of the variable without having to pass the variable's value as a parameter between the library and application.
    http://petboysherman.8m.com
    Trust, Love, and Magic.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I suppose that the header file contains the DECLARATION
    extern SCREEN g_screen;
    as per definition, the extern keyword marks a declaration.
    Then in some cpp file of the library there ought to be a
    SCREEN g_screen;
    (the definition) and if a change to g_screen in your main app doesn't affect the library then something's seriously wrong.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width