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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:46:09+00:00 2026-06-15T05:46:09+00:00

I want to hide the nature of a public struct for an API inside

  • 0

I want to hide the nature of a public struct for an API inside my .h/.c couple, so I declare only the typedef in the .h and I complete the declaration in the .c like this:

foo.h

typedef struct filters_s filters_t;

/* some public functions declaration using filters_t */
(...)

foo.c

typedef struct filters_s filter_node_t;

struct filters_s
{
  filter_node_t *children[96];

  (...)
}

As you can see, filters_s is in fact the root node of a tree so internally, I’m using filter_node_t but externally, I don’t want to expose the “tree” nature of the struct.
So, my “problem” is that ideally I’d like to have also another name for the struct like filter_node_s, but I don’t know if it’s possible.

  • 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-15T05:46:10+00:00Added an answer on June 15, 2026 at 5:46 am

    If you want to hide the implementation of the structure then you need a opaque pointer to the structure. There you would pass this pointer to a function that will get or modify the data of the structure.

    The declaration will be in the *.h header file. And the definition will be in the *.c file.

    Something like this in the *.h (header file):

    typedef struct tag_device device_t;
    

    Then in the *.c (implementation file):

    struct tag_device {
    size_t id;
    char *name;
    };
    
    void set_data(device_t *dev, size_t id, char *name)
    {
    dev->id = id;
    dev->name = strdup(*name);
    }
    

    Then in your *.c (driver file)

    device_t *device = malloc(sizeof *device)
    
    set_data(device, 1, "device02345");
    

    I have just typed this in, so it might not be perfect as I haven’t checked for errors. Always remember to free memory after you finish with it.

    Hope this helps

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

Sidebar

Related Questions

I want to hide this warning div using javascript inside it. I'm i getting
I want to hide framelayout dynmically in android, How I can achieve this.
I want to hide blocks of #ifdef and #ifndef blocks in C. Looks like
I want to hide page extensions like stackoverflow does. How does the following work?
I want to hide the button loadImgButton when I click it. This button will
I want to hide public methods from the IntelliSense member list. I have created
I want to hide the shadow on infowindow in Google Map API V3. I
I want to hide an image only when it is viewed from mobile or
I want to hide all blocks which only contain hidden DIVs (aside from a
I want hide some fields in existed XML and use that XML as Input

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.