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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:50:48+00:00 2026-06-17T23:50:48+00:00

I’ve been working on porting Marcel’s Simple Chess Program http://marcelk.net/mscp/ from C to C++.

  • 0

I’ve been working on porting Marcel’s Simple Chess Program http://marcelk.net/mscp/
from C to C++. I have never worked much with unions, much less structs within unions.
The top part I’ve listed is the declaration of the union. (All the code is in one .c file).

I’ve searched and read a few guides in addition to a C++ textbook, but I still have not gained any insight into how this could be fixed. I’m not sure what a “forward cdeclaration”
is nor in what context I should be looking at the problem.

My compile options are

g++ -ansi -Wall -O2 -pedantic -o mscp -mscp.cpp

static union {
        struct tt {                     /* Transposition table entry */
                unsigned short hash;    /* - Identifies position */ 
                short move;             /* - Best recorded move */
                short score;            /* - Score */
                char flag;              /* - How to interpret score */
                char depth;             /* - Remaining search depth */
        } tt[CORE];
        struct bk {                     /* Opening book entry */
                unsigned long hash;     /* - Identifies position */
                short move;             /* - Move for this position */
                unsigned short count;   /* - Frequency */
        } bk[CORE];
} core;

These portions are examples of the lines giving errors:

error: forward declaration of ‘const struct cmp_bk(const void*, const void*)::bk’

error: invalid use of incomplete type ‘const struct cmp_bk(const void*, const void*)::bk’

    static int cmp_bk(const void *ap, const void *bp)
    {
            const struct bk *a = ap; //ERROR HERE
            const struct bk *b = bp; //ERROR HERE

            if (a->hash < b->hash) return -1; //ERROR HERE
            if (a->hash > b->hash) return 1; //ERROR HERE
            return (int)a->move - (int)b->move; //ERROR HERE
    }

static int search(int depth, int alpha, int beta)
{
        int                             best_score = -INF;
        int                             best_move = 0;
        int                             score;
        struct move                     *moves;
        int                             incheck = 0;
        struct tt                       *tt; //ERROR HERE
        int                             oldalpha = alpha;
        int                             oldbeta = beta;
        int                             i, count=0;

               if (tt->depth >= depth) {
                    if (tt->flag >= 0) alpha = MAX(alpha, tt->score); //ERROR HERE
                    if (tt->flag <= 0) beta = MIN(beta,  tt->score); //ERROR HERE
                    if (alpha >= beta) return tt->score;
            }
            best_move = tt->move & 07777;      
  • 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-17T23:50:49+00:00Added an answer on June 17, 2026 at 11:50 pm

    Looks like you’ve declared a class or struct bk somewhere earlier in your code. Also

    struct tt                       *tt;
    

    Will produce a error because you’re trying to declares a variable with the same name as struct (both are called tt). Because of this error the variable is not properly declared and hence your other errors. In fact it looks like a lot of your problem’s stem from naming data types (eg bk, tt) the same thing as a variable. Try changing the name of the data types or making them anonymous if you can.

    As a side note the structs inside the union could probably be made anonymous unless they’re used anywhere else.

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

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
I have a text area in my form which accepts all possible characters from
I have been unable to fix a problem with Java Unicode and encoding. The
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

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.