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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:45:31+00:00 2026-05-28T06:45:31+00:00

I have a list of checkpoints and then a run a function. I originally

  • 0

I have a list of checkpoints and then a run a function. I originally built this list in that function, but now I have to build it outside. The problem is that I cannot include checkpoint.h in the class that implements that function because checkpoint.h returns a structure of the type of that class. The initial list was declare in class.c globally. How can I transfer the list created outside into class so I can use it?

So I have this header, turing_machine.h:

#ifndef __TURING_MACHINE__ 
#define __TURING_MACHINE__

#include "tape.h"
#include "alphabet.h"
#include "symbol_table.h"

...

#endif

and the checkpoint.h header defining the checkpoint_list class:

#ifndef __CHECKPOINT_H__
#define __CHECKPOINT_H__

#include "turing_machine.h"

...

#endif

So I want to send to a function from turing_machine.h a list of structures checkpoint but I can’t modify anything because that’s how the classes must stay.

I have also turing_machine.c:

#include "turing_machine.h"
#include "checkpoint.h"
#include "symbol_table.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

checkpoint_list *c;

So at the beginning I created in turing_machine that list, c, but now I must create it outside and I have to initialize that list c but I don’t know how. I hope this is more clear.

I used the term class wrong; I have just .c and .h files.

  • 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-28T06:45:31+00:00Added an answer on May 28, 2026 at 6:45 am

    Reading between the lines, somewhat, I think your trouble is that you have ‘mutually referencing’ structures.

    The way to work around this is with an incomplete type definition:

    typedef struct checkpoint_list checkpoint_list;
    

    You can then use that inside turing_machine.h:

    #ifndef TURING_MACHINE_H_INCLUDED
    #define TURING_MACHINE_H_INCLUDED
    
    #include "tape.h"
    #include "alphabet.h"
    #include "symbol_table.h"
    
    typedef struct checkpoint_list checkpoint_list;
    
    typedef struct turing_machine
    {
        ...
    } turing_machine;
    
    extern checkpoint_list *tm_function(turing_machine *);
    extern turing_machine  *tm_create(const char *); 
    
    #endif
    

    And, inside checkpoint.h, you can write:

    #ifndef CHECKPOINT_H_INCLUDED
    #define CHECKPOINT_H_INCLUDED
    
    #include "turing_machine.h"
    
    /* No typedef here in checkpoint.h */
    struct checkpoint_list
    {
        ...
    };
    
    extern checkpoint_list *cp_function(const char *);
    extern turing_machine  *cp_machine(checkpoint_list *);
    
    #endif
    

    This technique is recognized and defined by the C standard (C90, let alone C99 or C11).

    Note that I’ve also renamed the include guards; names that start with double underscore are reserved for ‘the implementation’ (meaning the C compiler and its libraries), and you should not invent and use such names in your own code.

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

Sidebar

Related Questions

I have list of rows that I have fetched using mysql_fetch_array() . Now I
i have list of rows that user select and i want to delete them,
I have list of files which contain particular patterns, but those files have been
I have List objects which are shown like this: www.mysite.com/lists/123 Where 123 is the
I have list of dictonaries. I wish type iterate over this list and map
I have list of items that need to be processed and printed to the
I have List like this List<string> items = new List<string>(); items.Add(-); items.Add(.); items.Add(a-); items.Add(a.);
i have List of int which consists of value 0,0,0,1,2,3,4,0,0 now i like to
I have List collection with around 35,000 strings Typical string looks like this: <i>füüs</i>ampri
I have list of contacts and then I have list of blocked contacts. I

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.