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 8739027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:51:19+00:00 2026-06-13T10:51:19+00:00

I have two functionally identical header files, one of which produces errors for no

  • 0

I have two functionally identical header files, one of which produces errors for no discernible reason. I must have done something wrong in creating the new (broken) file, but I can’t figure out what.

My IDE is Xcode. The project is compiled for Objective C++ using Apple LLVM Compiler 4.1, but the section of code in question is all pure C++, no Objective C.

Here’s some code:

NamespaceA.Common.h

#include "../NamespaceB/Common.h"

#include "WorkingClass.h"
#include "BrokenClass.h"

...

../NamespaceB/Common.h

#ifndef NamespaceBCommon
#define NamespaceBCommon

namespace NamespaceB
{
    ...
}

...
#include "Superclass.h"
...

WorkingClass.h

#ifndef NamespaceA_WorkingClass
#define NamespaceA_WorkingClass

namespace NamespaceA
{
    class WorkingClass : public NamespaceB::Superclass
    {
    public:

        WorkingClass();
        ~WorkingClass();
    };
}

#endif

BrokenClass.h

#ifndef NamespaceA_BrokenClass
#define NamespaceA_BrokenClass

// If I don't have this line I get errors. Why??                   !!!!!
// This file is exactly identical to WorkingClass.h 
// as far as I can tell!
//#include NamespaceA.Common.h

namespace NamespaceA
{            
    // Parse Issue: Expected class name                            !!!!!
    // Semantic Issue: Use of undeclared identifier 'NamespaceB'
    class BrokenClass : public NamespaceB::Superclass
    {
    public:

        BrokenClass();
        ~BrokenClass();
    };
}

#endif

Thank you.

  • 1 1 Answer
  • 0 Views
  • 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. Editorial Team
    Editorial Team
    2026-06-13T10:51:20+00:00Added an answer on June 13, 2026 at 10:51 am

    I found the problem. WorkingClass.cpp was including NamespaceA.Common.h and not including its own header file, rather than including the common file in the header and then including its own header file in the cpp.

    I managed to miss the #include in WorkingClass.cpp because I just assumed it was only including WorkingClass.h and not NamespaceA.Common.h.

    So in short:

    WorkingClass.h

    // Class goes here
    // No includes
    

    WorkingClass.cpp

    // Notice it does not include WorkingClass.h for whatever reason
    #include "NamespaceA.Common.h"
    

    NamespaceA.Common.h

    #include "../NamespaceB/Common.h"
    
    #include "WorkingClass.h"
    #include "BrokenClass.h"
    #include "EveryOtherClass.h" ...
    

    BrokenClass.h

    // Class goes here
    // No includes
    

    BrokenClass.cpp

    #include "BrokenClass.h"
    // Oh no! Where's NamespaceA.Common.h?
    

    I’m not a big fan of this include scheme, but I’ll live with it since it’s a large project that I don’t want to make sweeping changes to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two queries that are functionally identical. One of them performs very well,
I have two classes (MVC view model) which inherits from one abstract base class.
Have two folders with approx. 150 java property files. In a shell script, how
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two files client.php and server.php. The client file send a HTTP request
I have a script which contains two classes. (I'm obviously deleting a lot of
I have two CFC's which are Beans with DAO functions. I have set up
MDN says that valueOf and getTime are functionally equivalent. Why have two functions that
I have two different Search activities implemented with SearchManager in my app. One is
I have the following xml-node: val xml = <fields><field name=one></field><field name=two></field></fields> Now I would

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.