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

  • Home
  • SEARCH
  • 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 6331967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:10:21+00:00 2026-05-24T18:10:21+00:00

I have the following seemingly innocuous piece of code: #ifndef UI_H #define UI_H #include

  • 0

I have the following seemingly innocuous piece of code:

#ifndef UI_H
#define UI_H

#include <string>

namespace ui
{
    //Displays the main menu, showing loaded vocabulary cards
    //
    //Returns upon completion of display
    void displayMainMenu();

    //...More code like the above, just comments followed by functions
}

#endif

which gives me this error message:

filepath/ui.h:6: error: expected unqualified-id before 'namespace'

What am I doing wrong here?

  • 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-05-24T18:10:22+00:00Added an answer on May 24, 2026 at 6:10 pm

    One way to track down such errors is to start from the ground up:

    #include "filepath/ui.h"
    int main () { return 0; }
    

    Does this compile? (This works fine with the little snippet of ui.h that you supplied.)

    Errors like these are often caused by a missing semicolon on some previous class declaration. So let’s try to force the issue:

    struct Foo { int foo; } // Note the missing semicolon after the close brace.
    
    #include "filepath/ui.h"
    int main () { return 0; }
    

    This of course does not compile clean. I get a convoluted include path trace from my testmain.cpp to your filepath/ui.h to string … and eventually get

    /usr/include/i386/_types.h:37: error: two or more data types in declaration of '__int8_t'
    

    So that isn’t the error, but the missing semicolon sure is creating a mess. Your error isn’t arising deep in the bowels of <string>, so let’s make our test program #include <string> before trying to recreate the error:

    #include <string>
    struct Foo { int foo; } // Note the missing semicolon after the close brace.
    
    #include "filepath/ui.h"
    int main () { return 0; }
    

    And the error message is

    In file included from testmain.cpp:5:
    filepath/ui.h:6: error: expected unqualified-id before 'namespace'
    

    And there it is. So some other header that you #include prior to filepath/ui.h has a badly-formed class declaration.

    Addendum
    Sometimes it helps to use a different compiler. g++ is notorious for its bad treatment of this common programming error. Compiling the above with clang yields

    testmain.cpp:4:2: error: expected ';' after struct
    

    So, tada, clang has zeroed in on the problem.

    What is happening is that when a compiler runs into trouble it applies some fix to your code to make it grammatically correct. The compiler error message is based on this autocorrection. Note well: This autocorrection is in general a very good thing. Without it the compiler would necessarily have to shut down at the first error. Since programmers inevitably make more than one error, hunting them down one at a time would be a pain in the rear.

    I haven’t the foggiest idea what goofy correction g++ applies to fix the missing semicolon problem, other than it is not to add the obvious missing semicolon. clang adds the missing semicolon, and that is what it complains about.

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

Sidebar

Related Questions

I have the following HTML code stored in a javascript string: and I am
I thought the following task would be seemingly easy to code, but I have
I have following string String str = replace :) :) with some other string;
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,
I have following situation. A main table and many other tables linked together with
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section
I have the following code: int takeEven(int *nums, int numelements, int *newlist) { newlist
I have the following code: http://www.nomorepasting.com/getpaste.php?pasteid=22615 Which is called by the javascript mentioned in

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.