3

have a static function in a header file

    class Diagnostics {
    public:


    static void functionA(){
    }

    static void functionB(){
    some code //works fine until enters the loop below
    variable_name // works fine here.
    if (condition){ // 
    variable_name; // after condition is met , i step in here, debugger cannot examine
                   // the vairable_name which was fine above. right after i try to step                      over , i get SIGSEV error
    some_code; // doesnt even come here. Process exited with SIGSEV
    function C(); // tried using classname::functionC , didnt work either

        }
    }

static void functionC(){
}
cyrux
  • 233
  • 5
  • 15
  • 1
    What's the question? I wouldn't expect `variable_name` to be found - it's not mentioned anywhere in the class definition or in preceding code. And I don't see how the process can exit with SIGSEGV if it doesn't compile, which it won't if `variable_name` isn't found. – Steve Jessop Nov 03 '10 at 04:10
  • 1
    What is `variable_name`? What is `some_code`? Where are they defined? Also you're missing return types on your functions. – casablanca Nov 03 '10 at 04:10
  • 1
    Please show us the exact code. – Prasoon Saurav Nov 03 '10 at 04:10
  • Is variable name a non-static class member? if so that's your problem. – GWW Nov 03 '10 at 04:10
  • 5
    Well, I can't find `variable_name` either... – Mike DeSimone Nov 03 '10 at 04:10
  • This code won't compile. Standard C++ requires functions return type declarations. Though C89 and perhaps some older C++ compilers use `int` as the default return type. – Alex Jasmin Nov 03 '10 at 04:12
  • Also, your definition of `functionC` is *outside* the class, which makes it a non-member function. – Steve Jessop Nov 03 '10 at 04:14
  • functioC is not outside class. cleaned up code. void return types – cyrux Nov 03 '10 at 04:20

2 Answers2

4

static inside a class means that the member or method in question does not operate on an object, i.e. it doesn't define this, but it is still in the class's namespace.

static outside a class means what it means in C: the variable or function does not have external linkage, i.e. things outside the current compilation unit cannot link to it.

Two entirely different things.

Mike DeSimone
  • 41,631
  • 10
  • 72
  • 96
  • Perhaps you were confused because the OP had the code indented incorrectly. I have fixed it, you should see now why this answer doesn't work. (Namely `functionC` is a member of the class) – Billy ONeal Nov 03 '10 at 04:18
0

I dont know the problem was. Works fine now. initially happened while I was debugging. Then i just executed instead of debugging , worked fine. then i tried debugging again , which worked fine this time.

cyrux
  • 233
  • 5
  • 15