C
ciccio
Hi,
I have a problem with my code that the compiler does not find any inline
functions which are static.
The simple code example is written below, this is what the compiler
throws at me.
] $ g++ main.cpp foo.cpp
/home/klaas/tmp/cciAcYgl.o: In function `main':
inline.cpp.text+0x9): undefined reference to `foo::bar()'
collect2: ld returned 1 exit status
Is this normal behaviour??? I seriously doubt that.
If foo::bar(void) is not inline, it works.
When everything is written in one file, it works too.
regards,
This is the simple code
== foo.hpp ==
#ifndef _FOO_
#define _FOO_
class foo {
public:
static int a;
static int bar(void) ;
};
#endif
== foo.cpp ==
#include "foo.hpp"
int foo::a = 0;
inline int foo::bar(void) { return a; }
== main.cpp ==
#include "foo.hpp"
int main(void) {
int b = foo::bar();
return 0;
};
==========
I have a problem with my code that the compiler does not find any inline
functions which are static.
The simple code example is written below, this is what the compiler
throws at me.
] $ g++ main.cpp foo.cpp
/home/klaas/tmp/cciAcYgl.o: In function `main':
inline.cpp.text+0x9): undefined reference to `foo::bar()'
collect2: ld returned 1 exit status
Is this normal behaviour??? I seriously doubt that.
If foo::bar(void) is not inline, it works.
When everything is written in one file, it works too.
regards,
This is the simple code
== foo.hpp ==
#ifndef _FOO_
#define _FOO_
class foo {
public:
static int a;
static int bar(void) ;
};
#endif
== foo.cpp ==
#include "foo.hpp"
int foo::a = 0;
inline int foo::bar(void) { return a; }
== main.cpp ==
#include "foo.hpp"
int main(void) {
int b = foo::bar();
return 0;
};
==========