K
kelvSYC
I'm not sure if it violates standards or if it's just one of gcc's
quirks, but on gcc with Mac OS X (at least with my installation), for
some reason inline member functions that are not part of the class
declaration always produce linker errors.
For example, take a piece of my code:
// random access iterator for Cocoa Foundation's NSArray
// technically obj-c++, but only the c++ part that is relevant
class NSArrayIterator : std::iterator<...> {
// template arguments above not really relevant
unsigned int index;
public:
NSArrayIterator& operator++() { index++; return *this; }
};
The above compiles and links fine, but the one below gives out a linker
error
(NSArrayIterator.h)
class NSArrayIterator : std::iterator<...> {
unsigned int index;
//...
public:
NSArrayIterator& operator++();
};
(NSArrayIterator.mm)
inline NSArrayIterator& NSArrayIterator:perator++() {
index++;
return *this;
}
Is this supposed to be standard behavior (that it compiles but doesn't
link), a gcc quirk, or some other quirk? Is this issue similar to that
export and templates? If it's a gcc or linker thing, what should I set
in order for the second one to properly link?
quirks, but on gcc with Mac OS X (at least with my installation), for
some reason inline member functions that are not part of the class
declaration always produce linker errors.
For example, take a piece of my code:
// random access iterator for Cocoa Foundation's NSArray
// technically obj-c++, but only the c++ part that is relevant
class NSArrayIterator : std::iterator<...> {
// template arguments above not really relevant
unsigned int index;
public:
NSArrayIterator& operator++() { index++; return *this; }
};
The above compiles and links fine, but the one below gives out a linker
error
(NSArrayIterator.h)
class NSArrayIterator : std::iterator<...> {
unsigned int index;
//...
public:
NSArrayIterator& operator++();
};
(NSArrayIterator.mm)
inline NSArrayIterator& NSArrayIterator:perator++() {
index++;
return *this;
}
Is this supposed to be standard behavior (that it compiles but doesn't
link), a gcc quirk, or some other quirk? Is this issue similar to that
export and templates? If it's a gcc or linker thing, what should I set
in order for the second one to properly link?