Click here to Skip to main content
15,125,273 members
Articles / Programming Languages / C#
Alternative
Tip/Trick
Posted 8 Sep 2010

Tagged as

Stats

14.3K views
2 bookmarked

32-Bit or 64-bit OS ??

Rate me:
Please Sign up or sign in to vote.
3.62/5 (13 votes)
19 Sep 2010CPOL
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.

Comments and Discussions

 
GeneralReason for my vote of 1 wrong - others mentioned - just tell... Pin
johannesnestler14-Oct-10 4:55
Memberjohannesnestler14-Oct-10 4:55 
GeneralReason for my vote of 1 False Pin
Toli Cuturicu11-Oct-10 12:38
MemberToli Cuturicu11-Oct-10 12:38 
GeneralReason for my vote of 2 Not guaranteed to be the bit size of... Pin
BillW3330-Sep-10 9:40
professionalBillW3330-Sep-10 9:40 
GeneralReason for my vote of 1 This alternate is absurd and should ... Pin
Ajay Vijayvargiya19-Sep-10 11:52
MemberAjay Vijayvargiya19-Sep-10 11:52 
GeneralReason for my vote of 1 I'm afraid I don't agree. The tip wa... Pin
Luc Pattyn18-Sep-10 17:03
sitebuilderLuc Pattyn18-Sep-10 17:03 
GeneralReason for my vote of 5 Portable. The Best alternative. Pin
SpaceSoft16-Sep-10 5:06
MemberSpaceSoft16-Sep-10 5:06 
GeneralThis alternative doesn't hold true if judging Bitness of OS.... Pin
GPUToaster™12-Sep-10 20:28
MemberGPUToaster™12-Sep-10 20:28 
This alternative doesn't hold true if judging Bitness of OS. It only informs if the program is being run in 32/64-bit mode

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

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