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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:50:40+00:00 2026-05-28T19:50:40+00:00

I am designing a C API which among other things has to provide a

  • 0

I am designing a C API which among other things has to provide a way to set some double-valued options. To identify the options I use the following enum:

typedef enum
{
    OptionA,
    OptionB,
    ...
} Option;

Is it a good idea to use Option as a parameter type in a public API function:

int set_option(Option opt, double value);

or is it better to use int instead:

int set_option(int opt, double value);

considering that I may need to add more options in the future?

Also are there any good examples of existing APIs that demonstrate either approach?

  • 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-28T19:50:40+00:00Added an answer on May 28, 2026 at 7:50 pm

    By using an enum you are effectively helping the user of your function to know what valid values are available.
    Of course the drawback is that whenever a new option is added you will need to modify the header and thus the user may need to recompile his code whereas if it is an int he may not have to do that.

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

Sidebar

Related Questions

I am designing an API. It will have a lot of methods which do
I am currently designing a public-facing C++ API for a product which will require
I am designing RESTful Api's and would like some advice on designing an API
Are there any best practices to keep in mind while designing API's which ensures
I am designing a REST API where some resources can be filtered through query
I am designing an API for a C++ library which will be distributed in
I'm designing a Framework which I want to attach to the scripting language API
I am designing a WCF service which have some operations that i expose to
I am designing a web app that has some information that needs to be
I am designing a web API which requires fast read only access to 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.