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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:35:00+00:00 2026-05-26T12:35:00+00:00

i would like to use only certain functions from math.h (WITHOUT including the entire

  • 0

i would like to use only certain functions from math.h (WITHOUT including the entire library)

for example, i need to use “sqrt” and “exp”, but i have variables named “y1” (and possibly others) which conflict with definitions in math.h

how can i use only certain functions from a library like that?

i tried

#define sqrt cmath::sqrt

but that did not work, i have seen something like that before with

#define cout std::cout

i think, so i thought it might work.

any ideas?

  • 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-26T12:35:01+00:00Added an answer on May 26, 2026 at 12:35 pm

    Yes, you can just use the parts you want.

    Simply create your own partial mini_cmath.h header for those functions / globals you need access to (assuming those don’t conflict!).

    As several have noted, there’s no way to only #include a given chunk (unless the included header has preprocessor macros to enable such a thing, such as windows.h)

    But if you simply declare those functions you wish to use (correctly), and then compile & link (as long as the necessary .lib is included in your link), then you’re golden.


    However, on a more general note – globals are a bad idea in general, but if you absolutely must use them for hopefully valid reasons, then you should be putting them in a namespace, and referencing them in your source by fully qualified name:

    namespace AcmeCorp {
      int g_fubar;
    }
    AcmeCorp::g_fubar = 9;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I like Django, but for a particular application I would like to use only
I would like to use a css selector to get only the th tags
I would like to use Python's JSON module. It was only introduced in Python
I would like to use the EmailField in a form. However, instead of only
I am using AdoNetAppender (SQL server) in my asp.net application and would like use
I would like to use a language that I am familiar with - Java,
I would like to use something like CLR Profiles on .Net 2.0 to see
I would like to use as and is as members of an enumeration. I
I would like to use a component that exposes the datasource property, but instead
I would like to use client-side Javascript to perform a DNS lookup (hostname to

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.