Click here to Skip to main content
15,867,568 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

32-Bit or 64-bit OS ??

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


Written By
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 3:55
johannesnestler14-Oct-10 3:55 
GeneralReason for my vote of 1 False Pin
Toli Cuturicu11-Oct-10 11:38
Toli Cuturicu11-Oct-10 11:38 
GeneralReason for my vote of 2 Not guaranteed to be the bit size of... Pin
BillW3330-Sep-10 8:40
professionalBillW3330-Sep-10 8:40 
GeneralReason for my vote of 1 This alternate is absurd and should ... Pin
Ajay Vijayvargiya19-Sep-10 10:52
Ajay Vijayvargiya19-Sep-10 10:52 
GeneralReason for my vote of 1 I'm afraid I don't agree. The tip wa... Pin
Luc Pattyn18-Sep-10 16:03
sitebuilderLuc Pattyn18-Sep-10 16:03 
GeneralReason for my vote of 5 Portable. The Best alternative. Pin
SpaceSoft16-Sep-10 4:06
SpaceSoft16-Sep-10 4:06 
GeneralThis alternative doesn't hold true if judging Bitness of OS.... Pin
GPUToaster™12-Sep-10 19:28
GPUToaster™12-Sep-10 19: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.