Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 172513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:10:45+00:00 2026-05-11T13:10:45+00:00

Good evening :) I’m playing around with g++ and makefiles. I’ve gotten to this

  • 0

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 😀

Oh well, thanks anyway!

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:10:46+00:00Added an answer on May 11, 2026 at 1:10 pm

    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

    Dan Saks explains some reasons why you should typedef your class names, even though it might seem redundant.

    Well, you’ve run into real life situation where typedefing a class would have probably helped you find your problem a little easier:

     class bar {  // ...  };  typedef class bar bar; 

    Generates this more meaningful message if there’s a function named bar() already declared:

    In file included from C:\temp\foo.h:4,                  from C:\temp\test.cpp:4: C:\temp\bar.h:7: error: `typedef class bar bar' redeclared as different kind of symbol C:\temp\test.cpp:1: error: previous declaration of `void bar(int)' C:\temp\bar.h:7: error: declaration of `typedef class bar bar' 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good evening, I'm having an issue with Masonry. This is all my relevant code:
Good evening, I would like to have a navigation bar which is centralised to
Good evening, I just started playing with Microsoft.Contracts (latest version) and plugging it on
Good evening. For a project, I have to create a system. In this system,
Good evening fellow coders, and thank you in advance for any help/attention. This is
Good evening StackOverflow This time I'm fighting with a ListView Containing TextViews. I add
Good Evening, I'm building a website which will will look something like this: So
Good evening, I am tired and have been fighting with this for hours. I
Good evening :-)! I have this code to use Drag & Drop method for
Good evening, I am working to get my head around unit testing and I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.