Click here to Skip to main content
Click here to Skip to main content
Alternative Tip/Trick

Tagged as

32-Bit or 64-bit OS ??

, 19 Sep 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
In C++ you can use the size of a pointer to work out what sort of process you're running in:bool is_64_bit(){ return sizeof(void *) == 8;}This has got the advantage of being portable and you don't have to call any OS functions.You can do something similar in C - just return...
In C++ you can use the size of a pointer to work out what sort of process you're running in:
 
bool is_64_bit()
{
    return sizeof(void *) == 8;
}
 
This has got the advantage of being portable and you don't have to call any OS functions.
 
You can do something similar in C - just return an int instead.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Aescleal
Software Developer (Senior)
United Kingdom United Kingdom
I've been programming since 1985 - starting with Fortran 77, then moving onto assembler, C and C++ in about 1991. I also know enough Java and Python to read code but you probably wouldn't want me writing it.
 
I've worked in a wide variety of application areas - defense, banking, games and security with the longest stints being in security. I also seem to end up programming devices far too often. This time I'm programming terahertz band body scanners.
Follow on   Google+

Comments and Discussions

 
GeneralReason for my vote of 1 wrong - others mentioned - just tell... Pinmemberjohannesnestler14-Oct-10 4:55 
GeneralReason for my vote of 1 False PinmemberToli Cuturicu11-Oct-10 12:38 
GeneralReason for my vote of 2 Not guaranteed to be the bit size of... PinmemberCIDev30-Sep-10 9:40 
GeneralReason for my vote of 1 This alternate is absurd and should ... PinmemberAjay Vijayvargiya19-Sep-10 11:52 
GeneralReason for my vote of 1 I'm afraid I don't agree. The tip wa... PinmvpLuc Pattyn18-Sep-10 17:03 
GeneralReason for my vote of 5 Portable. The Best alternative. PinmemberSpaceSoft16-Sep-10 5:06 
GeneralThis alternative doesn't hold true if judging Bitness of OS.... PinmemberGPUToaster12-Sep-10 20:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411019.1 | Last Updated 19 Sep 2010
Article Copyright 2010 by Aescleal
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid