Static Member Functions

I'm running into some errors that I'm not entirely sure how to correct. I did not write this code - I'm updating it - and I want to ensure I know what the original intent was prior to changing a bunch of stuff.

Error:
1
2
3
4
5
6
7
ld: fatal: symbol `Abend::Exit(char const*, ...)' is multiply-defined:
        (file ./SiteAggregator.o type=FUNC; file ./Abend.o type=FUNC);
ld: fatal: symbol `Abend::_CleanupFunc' is multiply-defined:
        (file ./SiteAggregator.o type=OBJT; file ./Abend.o type=OBJT);
ld: fatal: File processing errors. No output written to SiteReport
collect2: ld returned 1 exit status
gmake: *** [SiteReport] Error 1


Abend.h (section)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Abend
{

public:

    static void SetCleanup( void (*func)() ) { _CleanupFunc = func; }

    static void Exit( const char* format, ... );

private:

    static void (*_CleanupFunc) ();

/// Private Functions

    ////////////////////////////////////////////////////////////////////////////
    // -- DEFAULT FUNCTIONS made PRIVATE so that they never get called.
    ////////////////////////////////////////////////////////////////////////////

    Abend();

    Abend(const Abend&);

    Abend operator=(const Abend&);

};


Abend.cpp (section)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
////////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
////////////////////////////////////////////////////////////////////////////////

void (* Abend::_CleanupFunc) () = 0;

////////////////////////////////////////////////////////////////////////////////
// Class Functions
////////////////////////////////////////////////////////////////////////////////

// -- PUBLIC FUNCTIONS

void Abend::Exit( const char* format, ... )
{
    printf("\nABEND: " );

    // Print like printf
    va_list args;
    va_start( args, format );
    vprintf( format, args );  // Print the error message
    va_end( args );

    // Finish, cleanup and exit
    printf("\n\n" );
    if( _CleanupFunc ){
        _CleanupFunc();
    }
    exit(1);
}


Can anyone shed some light as to what the issue might be?
It sounds like including that header file in more than one file is violating the one definition rule. The problem must be in the header file itself. Headers typically contain declarations not definitions (class definitions and inline function definitions are ok).
Last edited on
Topic archived. No new replies allowed.