Static variable usage

This is a discussion on Static variable usage within the C Programming forums, part of the General Programming Boards category; Dear All, I have one doubt in static variable:- file 1:- BSISCOOR_Coordinator_COMMON.C contains one variable { STATIC UWORD gs_BSISCOOR_CvrtCycCounter_UW ; ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    83

    Static variable usage

    Dear All,
    I have one doubt in static variable:-

    file 1:- BSISCOOR_Coordinator_COMMON.C contains one variable
    {

    STATIC UWORD gs_BSISCOOR_CvrtCycCounter_UW;
    }
    Now i wanted to use this variable in another file. first i declared above variable in one defination file as follows:
    defination file: PSWASW_CustomerSpecific_BB29047.h
    {
    Code:
     
                    extern UWORD gs_BSISCOOR_CvrtCycCounter_UW;
                  }
    I have included above defination file in my file2 as follows:-
    file 2: - DIO_DigitalOutput_BB63215.C
    {
    [code]
    #include PSWASW_CustomerSpecific_BB29047.h
    [\code]
    }

    When i compile above file i am getting following error:-
    i am using VC++ compiler.

    ### Syntax checking ..\PSW\HSW\HSW15_COMMON\BSISCOOR_COMMON\SRC\BSISCO OR_COORDINATOR_COMMON.ESC...
    "..\Psw\HSW\HSW15_COMMON\BSISCOOR_COMMON\SRC\BSISC OOR_Coordinator_COMMON.ESC", line 1767: error #174-D:
    external/internal linkage conflict with previous declaration
    STATIC UWORD gs_BSISCOOR_CvrtCycCounter_UW;


    Where i am going mistake?

    Thanks in advance
    Swetha

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    A static variable, by definition, is not visible to other modules. You need to remove the static completely. Global variables are bad anyway.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Need some help...
    By darkconvoy in forum C Programming
    Replies: 32
    Last Post: 04-29-2008, 03:33 PM
  3. How make static variable for across threads?
    By 6tr6tr in forum C++ Programming
    Replies: 10
    Last Post: 04-22-2008, 08:32 AM
  4. static variable in templates
    By arjunajay in forum C++ Programming
    Replies: 8
    Last Post: 11-21-2005, 07:44 AM
  5. Replies: 3
    Last Post: 10-10-2002, 07:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21