problem with static char

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yang__lee@ausi.com

    problem with static char

    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

  • Ron Natalie

    #2
    Re: problem with static char

    yang__lee@ausi. com 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.

    Comment

    • Ron Natalie

      #3
      Re: problem with static char

      yang__lee@ausi. com 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.

      Comment

      • Victor Bazarov

        #4
        Re: problem with static char

        Ron Natalie wrote:
        yang__lee@ausi. com 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


        Comment

        • Victor Bazarov

          #5
          Re: problem with static char

          yang__lee@ausi. com 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


          Comment

          Working...