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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:52:29+00:00 2026-05-31T01:52:29+00:00

The error I get when I try to print out this list is an

  • 0

The error I get when I try to print out this list is an incompatible type error. I tried casting it as struct macro, static struct macro, a pointer, and none of it work.

struct macro {
  struct macro *next;
  char * macro_name;
  char * macro_body;
};

static struct macro macro_list = {
  .next = NULL,
  .macro_name = NULL,
  .macro_body = NULL
};

//--------------------------------------------------------------------------------

void macro_list_print(void){
  printf("Printing macro_list\n");
  if(macro_list.next == NULL){
    printf("--No macros\n");
  }
  struct macro p = macro_list;
  while(p.next != NULL){
    printf("%s %s\n",p.macro_name,p.macro_body);
    p = macro_list.next; //This line gives me the error. 
  }
}

I can’t figure out what to do here. Any help would be appropriated thanks.

  • 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-31T01:52:30+00:00Added an answer on May 31, 2026 at 1:52 am

    p is a struct macro whereas macro_list.next is a struct macro*. Change to:

    struct macro* p = &macro_list;
    while(p != NULL){
        printf("%s %s\n",p->macro_name,p->macro_body);
        p = p->next;
    }
    

    I made the following additional changes:

    • macro_list.next to p->next, otherwise it would never have gotten past the second item in the list.
    • changed the condition in the while to p != NULL, otherwise it would not have processed the last element in the list as it was checking p->next != NULL
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error when I try to use time_ago_in_words : Comparison of String
If I try to implement my class on this file I get an error
whenever I try to call my ejb from a client, I get this error
When we try to create a view within a funcion we get ERROR: there
When I try to do that I get the error Changed to 64-bit applications
Why do i get an error when I try using _ instead of using
When I try to do a file(' http://somewebsite.com ') i get an error URL
When I try to open a project's CodeAnalysis page I get the error An
When I try to run the following, I get an error back from ActiveRecord
When I try user = System.Web.UI.Page.CurrentUser or user = System.Web.UI.Page.User.Identity I get an error

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.