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

The Archive Base Latest Questions

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

Some standard C libraries that I want to access with Cython have a ton

  • 0

Some standard C libraries that I want to access with Cython have a ton of flags. The Cython docs state that I must replicate the parts of the header I need. Which is fine when it comes to functions definitions. They are usually replicated everywhere, docs included. But what about all those magic numbers?

If I want to call mmap, I can always find the function definition and paste it into a .pxd file:

void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)

But calling it needs a ton of flags like PROT_READ, MAP_ANONYMOUS and so on. I have at least two problems with this:

Firstly, it is annoying work to hunt down exactly where those numbers are defined. In fact I’d rather write a .c file and printf the values I need. Are there any better way of finding the value of a given flag such as PROT_READ?

Secondly, how stable are these numbers? Having extracted all the values I need and hardcoded them into my Cython source, what are the chances that compiling on a different platform has switched around, let’s say PROT_READ and PROT_EXEC?

Even if the answer is that there are no good or proper ways to do it, I’d like to hear it. I can always accept that something is cumbersome as long as I know I’m not missing something.

  • 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-13T15:30:12+00:00Added an answer on May 13, 2026 at 3:30 pm

    To use these constants from Cython, you don’t need to figure exactly where they came from or what they are any more than you do from C. For example, your .pxd file can look like

    cdef extern from "foo.h":
        void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
        cdef int PROT_READ
        cdef int MAP_ANONYMOUS
        ...
    

    As long as the definitions are (directly or indirectly) included from foo.h, this should work fine.

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

Sidebar

Related Questions

I use some libraries that I don't want built as part of every project
I have some simple shell scripting tasks that I want to do For example:
I have a console application that prints on standard output. I want to implement
There are some third party Javascript libraries that have some functionality I would like
In C#, I am developing several Windows Services which have some standard functionality so
this is just some pretty standard code I have tried. What I am trying
I have some js (show/hide pretty standard I guess): <script> function showTransactions(transactions){ $('.steps').hide() $('#'
What recommendations do you have for a Subversion client that supports Microsofts standard SCC
I have a particular function (well, set of functions) that I want to start
is there some standard about how to graphically represent database schemas? Is UML a

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.