I have the need/desire to learn to program against Win32 in C++. I am a little confused as to what Win32 even is, as I have no experience on the platform.
What would you recommend to get me started programming and debugging C++ programs on Win32?
I have the need/desire to learn to program against Win32 in C++. I am a little confused as to what Win32 even is, as I have no experience on the platform.
What would you recommend to get me started programming and debugging C++ programs on Win32?
Win32 usually refers to the Win32 API, which can be used to interact with the Windows operating system. It can also refer to the platform, which is the 32 bit version of Windows. To compile for it, you will need a compiler such as Microsoft Visual C++ or MinGW/gcc.
Whoa, hold on here. This is a huge topic. Are you trying to cram learn what Win32 is for a job interview or something? If you need to learn Win32, you need THE book, Programming Windows 5th Edition by Charles Petzold:
http://www.charlespetzold.com/pw5/
It doesn't matter that its old; it virtually all still applies.
Answering your questions one by one:
1/ Will anyone tell me what Win32 is?
Win32 is the application programming interface (API) for Windows. Specifically, it's for 32-bit Windows and beyond since the old API was for the primarily 16-bit versions of Windows, Windows ME and before.
Aside: I'm pretty certain Microsoft may want to forget ME ever existed and just rewrite the history books to say that they went straight from Win98 to Win2k; something they'll probably also want to do with another of their products: "Vista, what Vista? All we know about is Windows XP and Windows 7". :-)
The first Windows version to fully support Win32 was Windows NT.
The API is the set of calls you are permitted to make. For Windows, it includes such things as window creation and manipulation, multi-threading, graphics drawing, text rendering and so on. Basically it's how your program interfaces to the Windows operating system to get things done.
Companies publish their APIs so that clients can do useful things with them. There are other ways to get the products to do things but these are generally known as undocumented features and, while a good company will go out of its way to ensure later versions of the API don't break your code, the use of undocumented features is not their problem. Use them at your own peril.
2/ How to I compile and execute c++ program in win32?
To do that, you'll need a compiler. Popular choices are Microsoft Visual C++ (you can get the Visual Express edition for free from Microsoft), CygWin or MinGW (the minimalist GNU for Windows). Search Google for "free c++ compilers for windows".
A compiler takes C++ source code and turns it into executable code, able to be run on the target system (Windows in this case).
Once you have an executable, you run it as you would any other program. If you create the executable do_something.exe
in your path, just type do_something
from a command line.
The compilers don't restrict you to just command line tools, they also allow you to create full-blown graphical applications so you can just double-click on the executable in File Manager, or make an associated file type to run the executable automatically for specific file types.
3/ How do I debug in win32 with c++ program?
The Visual C++ integrated development environment (IDE) has the compiler and a debugger included in it. Debugging is relatively painless as you can simply step through each line of the program and examine its behaviour. Other environment such as MinGW and CygWin have command-line debuggers which are not as closely aligned to Windows as Visual C++.
But I have to admit, I sometimes still find myself debugging by inserting printf
statements in my code and recompiling. Old habits die hard.
4/ What other things do I have to know while I am writing c++ program in win32?
I hardly know where to begin. You have a long (but hopefully enjoyable) journey in front of you. It might be wise to check back here with other specific questions once you have organised to install a compiler and have tried to get your first program compiled and running.
Best of luck.
Formally the Windows API is Microsoft's core set of application programming interfaces. For someone in a hurry! Get Microsoft Visual Studio. Start it up and choose Files->New Project and select Visual C++ and Win32 Console Application. This will get you started quickly and debugging is easy.
You can download free versions of Visual Studio Express (e.g., Visual C# Express, Visual C++ Express), from here and, although they don't have the more advanced features of those products, they're still very good for learning.