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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:33:56+00:00 2026-06-14T04:33:56+00:00

I have a Parser.h , that defines a struct StmtParent : … struct StmtParent;

  • 0

I have a Parser.h, that defines a struct StmtParent:

...
struct StmtParent;

class Parser {
...

Then in Parser.cpp:

struct StmtParent {
    int stmtNo;
    int parent;
};
... 

Seems all right? Then I have a unit test (cppunit):

# in ParserUnitTests.h
#include "header\Parser.h"

# in ParserUnitTests.cpp
void ParserUnitTests::testParseProcSideEffects() {
...
stack<StmtParent> follows;
    ...

Then I get errors like:

error C2027: use of undefined type 'StmtParent'

Why, I can use functions like Parser::parseLine(). Why can’t I access the struct? So I tried including Parser.h in ParserUnitTests.cpp (although I already have it included in the header). Then I get:

Error   8   error C2146: syntax error : missing ';' before identifier 'm_cCurToken' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\parser.h    52
Error   9   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\parser.h    52
Error   10  error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\parser.h    52
...
  • 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-14T04:33:58+00:00Added an answer on June 14, 2026 at 4:33 am

    Parser.h does not define the struct, it forward-declares it. Therefore it’s incomplete when you try to use it as a template parameter for the stack, and you can’t use incomplete types as parameters for STL containers:

    C++11 draft 3035, 17.4.3.6, paragraph 2:

    In particular, the effects are undefined in the following cases:

    …

    if an incomplete type (3.9) is used as a template argument when instantiating a template component,
    unless specifically allowed for that component.

    You can check this out for reasoning.

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

Sidebar

Related Questions

I have a Ruby script that defines a class. I would like the script
I have a parser that we implemented and I want to compare it to
I have made a XML parser that list correctly in the UITableViewController. It passes
I have a buggy xml that contains empty attributes and I have a parser
I am using Happy to generate a parser. I have found that when I
I have a C++ project that uses a C bison parser. The C parser
I have XML content in a string that defines its encoding in its declaration.
I have an assembly that defines a UserControl X. Within that assembly, X is
I have a problem about designing. I should use class or struct in this
I have this class in my parser.py file class HostInfo(object): def __init__(self, host_id): self.osclass

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.