problem with static char

Discussion in 'C++' started by yang__lee@ausi.com, Apr 19, 2007.

  1. Guest

    Hi,

    I am facing a problem .

    In VS 2006 I have created a win32 static library.

    in one of the functions I have declared a variable as

    static char path[1000]="\0";

    I link this library to another exe.

    WHile debugging when control comes on this declaration,

    it doesn't identify path.

    I tried to copy "path" to watch window but it says symbol not found.

    Why is that so.

    My OS is windows XP . is it that .net 2005 that was instaleld.

    Kindly let me know.

    regards

    Vijay
     
    , Apr 19, 2007
    #1
    1. Advertising

  2. Ron Natalie Guest

    wrote:
    > Hi,
    >
    > I am facing a problem .
    >
    > In VS 2006 I have created a win32 static library.
    >
    > in one of the functions I have declared a variable as
    >
    > static char path[1000]="\0";
    >
    > I link this library to another exe.
    >
    > WHile debugging when control comes on this declaration,
    >

    You're probably not in a function where path is in the scope.
    The static storage class specifier implies internal linkage.
    Contexts outside of that file can't see it.
     
    Ron Natalie, Apr 19, 2007
    #2
    1. Advertising

  3. Ron Natalie Guest

    wrote:
    > Hi,
    >
    > I am facing a problem .
    >
    > In VS 2006 I have created a win32 static library.
    >
    > in one of the functions I have declared a variable as
    >
    > static char path[1000]="\0";
    >
    >

    The above construct is deprecated. Put the variable in a
    (possibly unnamed) namespace.
     
    Ron Natalie, Apr 19, 2007
    #3
  4. Ron Natalie wrote:
    > wrote:
    >> Hi,
    >>
    >> I am facing a problem .
    >>
    >> In VS 2006 I have created a win32 static library.
    >>
    >> in one of the functions I have declared a variable as
    >>
    >> static char path[1000]="\0";
    >>
    >>

    > The above construct is deprecated. Put the variable in a
    > (possibly unnamed) namespace.


    Twice you posted and it seems twice you missed the fact that
    the OP said "in one of the functions ...". The 'path' does
    *not* have namespace scope.

    The OP's problem is with VC++ debugger, which doesn't have
    the ability to identify static local variables.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Apr 19, 2007
    #4
  5. wrote:
    > Hi,
    >
    > I am facing a problem .
    >
    > In VS 2006 I have created a win32 static library.


    What's VS 2006? Do you mean Visual C++ v6?

    > in one of the functions I have declared a variable as
    >
    > static char path[1000]="\0";
    >
    > I link this library to another exe.
    >
    > WHile debugging when control comes on this declaration,
    >
    > it doesn't identify path.
    >
    > I tried to copy "path" to watch window but it says symbol not found.
    >
    > Why is that so.


    Because VC++ debugger is buggy, most likely.

    > My OS is windows XP . is it that .net 2005 that was instaleld.


    Huh?

    > Kindly let me know.


    The solution is relatively simple. Add another variable

    const char (&rpath)[1000] = path;

    (right after your 'path'), and use that variable to examine the
    contents of the array in the debugger.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Apr 19, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wwj
    Replies:
    7
    Views:
    581
  2. wwj
    Replies:
    24
    Views:
    2,548
    Mike Wahler
    Nov 7, 2003
  3. Ben Pfaff
    Replies:
    5
    Views:
    490
    Tristan Miller
    Jan 17, 2004
  4. lovecreatesbeauty
    Replies:
    1
    Views:
    1,099
    Ian Collins
    May 9, 2006
  5. Replies:
    3
    Views:
    745
Loading...

Share This Page