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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:14:56+00:00 2026-05-17T22:14:56+00:00

I occasionally use 64 bit arithmetic in an open source C++ library of mine.

  • 0

I occasionally use 64 bit arithmetic in an open source C++ library of mine. I discovered that long long serves my purpose quite nicely. Even some 10 year old solaris box could compile it. And it works without messing around with #defines on Windows too.

Now the issue is I get complaints from my users because they compile with GCC -pedantic settings, and GCC insists on issuing warnings that long long is not part of the C++ standard. This is probably right, but I am not too interested in the C++ standard per se, I just want my code to work on as many compilers as reasonably possible.

So my question is twofold:

  • can anyone name actual C++ compilers that don’t support 64 bit long long’s?
  • is there a way to make GCC compile 64 bit arithmetic (on 32 bit platform) without compiler warnings? (stdint.h does not help, as it also depends on long long)

P.S.

If there are platforms where long longs become 128 bit or bigger, that is interesting, but not a problem for me.

  • 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-17T22:14:57+00:00Added an answer on May 17, 2026 at 10:14 pm

    When your library is provided as source, one option is to provide a “porting” header, in which it is your users’ responsibility to provide a 64 bit type (you’d specify the name). It’s then also naturally their responsibility to deal with any compiler warnings that their choice of type provokes, either avoid them, suppress them, or ignore them.

    I guess this is what you call “messing around with #defines”, but I don’t think there’s too much wrong with it. You can provide a default version which just uses long long directly and will work on your 10-year-old Solaris box and also on Windows, so most users would never need to go near the user-configurable part of your library.

    Then for the pedantic users, you can provide a version for GCC which includes <sys/types.h> and uses int64_t instead of long long. This doesn’t provoke any warning for me with g++ -pedantic. You could even do this in the default version by recognising GCC, which certainly is messing around with #defines, but again not in a way that’s at all unusual for a multi-platform product.

    If your library is also provided as binaries for certain platforms, then of course you have to decide what the 64 bit type is going to be. If it also appears in the library interface (and hence the header file), then you’ll just have to choose one which will not provoke any warnings with reasonable compiler options. I think -pedantic is a reasonable compiler option, and apparently so do your users, so again that’s int64_t on GCC.

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

Sidebar

Related Questions

I have a Windows application written in C++ that occasionally evaporates. I use the
Occasionally, I've come across a webpage that tries to pop open a new window
Occasionally while attempting to save a Crystal Report that I'm working on in VS2008,
Occasionally I come accross a unit test that doesn't Assert anything. The particular example
Occasionally, when I open a visual studio 2003 ASP.NET project it seems to spend
I occasionally use a volatile instance variable in cases where I have two threads
Occasionally I need to use fixed-width integers for communication with external devices like PLCs.
I hear about it a bit in tutorials that I watch, that certain things
We have built a Windows Service that is running on client's machines, which occasionally
Occasionally in low-memory conditions the UIImagePickerController I use gets 'stuck' with the shutter closed.

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.