Good evening :)
I'm playing around with g++ and makefiles. I've gotten to this point:
foo.h:
#ifndef _FOO_H_
#define _FOO_H_
#include "bar.h"
class foo {
private:
bar something;
public:
bool start();
bool stop();
};
#endif // _FOO_H_
Foo.h is eventually included in my main cpp file so I can set things in motion by calling start/stop.
void somewhere() {
foo* hihi = new foo;
hihi->start();
delete hihi;
}
Then there's bar.h:
#ifndef _BAR_H_
#define _BAR_H_
class bar {
};
#endif // _BAR_H_
g++ doesn't seem to like it however:
g++ (some_flags) -c main.cpp
In file included from main.cpp:2:
foo.h:8: error: ‘bar’ does not name a type
I'm using makefiles, and tried a combination of things like:
main.o: main.cpp foo.h bar.h
Even though I don't think I should have to add bar.h here, shouldn't including it in foo.h be enough?
To clarify, this is roughly how it's set up now (yes I know this can be done in a more efficient manner):
main.o: main.cpp foo.h
$(CC) $(CFLAGS) -c main.cpp
foo.o: foo.h foo.cpp
$(CC) $(CFLAGS) -c foo.cpp
bar.o: bar.h bar.cpp
$(CC) $(CFLAGS) -c bar.cpp
What's going on? I figure it's something I'm missing about g++ and the way it handles header includes, point me in the right direction please!
edit - found the solution:
Doh! I feel dumb right now. Was messing around with boost::asio and kind of forgot I still left this on top of my headers somewhere: using boost::asio::ip::tcp;
Let's just say there's a boost::asio::ip::tcp::bar function :D
Oh well, thanks anyway!