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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:46:13+00:00 2026-05-26T15:46:13+00:00

Though I rarely write C code, I often see it (mostly due to books

  • 0

Though I rarely write C code, I often see it (mostly due to books in my field having it as sort of reference language for algorithm examples) and something has been bugging me for a while about the way variables/parameters are declared. The best example would be this List with a twist example, about a particular implementation of Linked List used in Linux kernel (sorry, I had a link to a blog post originally, but apparently the blog post has been deleted, I copied code from my browser’s cache).

struct blog {
  ...
  struct ls posts;
};

struct post {
  ...
  struct ls blog_posts;
};

void delete_blog(struct blog *blog) {
  ...
  struct post *p;
  ls_for_each(&blog->posts, p, blog_posts) {
    free(p);
  }
  free(blog);
}

What bugs me is the fact that they keep repeating the keyword struct everywhere. I mean things like ls, blog, post are declared as structs, so what is the point of saying it is a struct every time you declare a variable or a function parameter of that type? What does this tell the compiler that it can’t infer from the fact that the thing you are instantiated has been defined as a struct?

  • 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-26T15:46:14+00:00Added an answer on May 26, 2026 at 3:46 pm

    Well, it’s because if there isn’t a typedef, that’s the only way to refer to the struct.

    In C, if you have:

    struct thing {
      // stuff here
    };
    

    and you want to have a variable of that type, you need to either:

    • use struct thing as the type specifier
    • make a typedef like typedef struct thing thing_t; and use thing_t as the type specifier.

    (C++ is different in this respect.)

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

Sidebar

Related Questions

Even though it is possible to write generic code in C using void pointer(generic
Even though I always strive for complete validation these days, I often wonder if
Quite embarassing issue, though i come from web development and rarely have to deal
It seems that I rarely, if ever, see or use a ruby constructor in
My particular case deals with Ruby, though it could apply to almost any language.
Up until now I've mostly concentrated on how to properly design code, make it
Even 2 decades ago, it was possible to call code written in one language
I've written a simple, though highly multi-threaded, prime numbers generator. The algorithm goes like
I'm trying to enumerate through arrays using the enumerateObjectsWithOptions:usingBlock method. However, my code rarely
I very rarely meet any other programmers! My thought when I first saw the

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.