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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:04:16+00:00 2026-06-11T01:04:16+00:00

looking at the source code of GMPlib (the Gnu library for multy-precision calculations) I

  • 0

looking at the source code of GMPlib (the Gnu library for multy-precision calculations) I found this kind of code for building its mp*_t structures. And I have replicated it in various other works I have done, but I don’t fully understand it.

typedef struct
{
  int _mp_alloc;           /* Number of *limbs* allocated and pointed
                              to by the _mp_d field.  */
  int _mp_size;            /* abs(_mp_size) is the number of limbs the
                              last field points to.  If _mp_size is
                              negative this is a negative number.  */
  mp_limb_t *_mp_d;        /* Pointer to the limbs.  */
} __mpz_struct;

I understand that this defines the ‘shape’ of a structure with two integers and a mp_limb_t and typedefs it to __mpz_struct

Then comes this line:

typedef __mpz_struct mpz_t[1];

And after a while, this other one:

typedef __mpz_struct *mpz_ptr;

I understand that the second one is typedefining __mpz_struct * to mpz_ptr (Which is used in the function prototypes)

But I don’t understand what the first one does and why it works so I can declare a mpz_t. Can anyone explain why it works?

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-06-11T01:04:18+00:00Added an answer on June 11, 2026 at 1:04 am

    The simplest way to understand a typedef is the rule Define it like you use it. In other words, when you declare a typedef you’re making a new name, but should you remove the typedef keyword you’ll get an object of the aliased type.

    For example:

    typedef __mpz_struct mpz_t[1];
    

    This makes a new type name, called “mpz_t”. But if we rewrite:

    __mpz_struct some_obj[1];
    

    we immediately understand it makes an array of whatever __mpz_struct is. So now we know what the new type mpz_t a does: it makes an array of __mpz_struct with one element.

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

Sidebar

Related Questions

Looking at some source code, I found this operator () => { } From
While looking at some source code I found this: require[./helpers] = new function() {...};
Looking at SharpDevelop source code I found this button declaration: <Button Style={x:Static core:GlobalStyles.ButtonStyle} Content={core:Localize
Looking at the source code of pstats I see this syntax: print >> self.stream,
I occasionally run into this type of syntax when looking through open source code
Nowadays I am looking python source code, and I found both python and C#
I was looking at the source code for ncmpcpp, and I saw this. #include
While looking at the source code of System.ServiceModel.Channels.BufferManager, I noticed this method: void TuneQuotas()
I was looking at the source code for the Underscore.js library, specifically for the
I was looking at this source code and in the attributes declaration there is

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.