Sign in to follow this  
Jaykumar

windows programming basics

Recommended Posts

Hi i'm new to window app programming. i started off with the book "Tricks of the windows game programming by Andre Lamothe" suggested at the resources section of gamedev. I started off with the simplest code.. the msg box code.... the author has used the windows.h and windowsx.h header files.. im using the Microsoft Visual C++ 6 Enterprise edition.. but when i compile the code it returns an error.. however if i select a win32 app project.. it automatically includes the stdafx.h header and the msg box code works.. I get confused between these header files... I kn it is stupid askin this.. but pls.. i need help.. Cheers

Share this post


Link to post
Share on other sites
Quote:
Original post by Jaykumar
im using the Microsoft Visual C++ 6 Enterprise edition..


;____;

You should do everything in your power to release yourself from something so terrible; do yourself a favor and use Microsoft Visual Studio 2008 Express instead.

Quote:
Original post by Jaykumar
but when i compile the code it returns an error..


What kind of error do you get?

Quote:
Original post by Jaykumar
however if i select a win32 app project.. it automatically includes the stdafx.h header and the msg box code works..


There's some header in stdafx.h or some project setting that's allowing your code to compile or run, depending on what problem you're having.

My first guess is that its a const char* to LPCWSTR conversion error; if that's the case, you should change "Character set" in the project properties from "Use Unicode Character Set" to "None", or prefix all constant strings with L and use wchar_t instead of char. However, I'm not sure how Visual Studio 6 handles the default project properties since it's incredibly ancient and broken.

Share this post


Link to post
Share on other sites
There are two types of C++ programs you can create. Console applications (black window with white text) or a windows application (GUI elements). Depending on which you have chosen you may get compiler errors if you declare your main function incorrectly.

the stdafx file is your pre-compiled header. You need to make sure that "use precompiled headers" is selected that you handle them properly for all your cpp files. If you forget to include stdafx.h then the compiler will complain. You also need to make sure that the stdafx.cpp file is set to "create precompiled headers" not "use...." or you'll get an error.

Post the error messages that you are getting and it will help us help you!

Share this post


Link to post
Share on other sites
Hi ppl

this was the error i got:
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/prog1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

prog1.exe - 2 error(s), 0 warning(s)


Thanks for ur help ppl. :)


i wanted to kn if its fine for a beginner to start off visual studio 2008? also will i be able to use <windows.h> in 2008 jus like in the tutorials?

cheers


Share this post


Link to post
Share on other sites
I was wondering, what's so bad about Microsoft Visual C++ 6 Enterprise? I don't know much about IDEs so I can't answer that question myself.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ntvu
I was wondering, what's so bad about Microsoft Visual C++ 6 Enterprise? I don't know much about IDEs so I can't answer that question myself.
It's not so much the IDE that's the problem as the "C++" compiler, which pre-dates the standardisation of C++ and as such doesn't compile proper C++ correctly (and will also compile improper C++).

Share this post


Link to post
Share on other sites
I am a professional programmer who used Visual C++ 6 professionally for more than 3 years (around 2000-2002) ... which it was one of the best at the time (Borland was better in some ways) it is not appropriate for modern use really.

1. It isn't a proper modern C++ compiler. This means it won't properly compile many templated libraries that use cutting edge features (many things from www.boost.org will not work correctly).

2. The IDE has many limits / flaws, such as only being able to open 3 instances at once before it screws us, and crashes and hangs if you use it a lot opening and closing projects and MSDN help repeatedly. It also doesn't always "build" when you tell it to, because its up-to-date detection is flawed.

The newer Visual Studio 2008 IDE is much better in many ways (although worse in a few small ones ... and it does use more memory).

The only benefit to Visual C++ 6 / Reason to use it ... is if you have projects your are downloading that are built in Visual C++ 6 - and since it was the dominate compiler for over 5 years ... there are MANY MANY older projects available for it which haven't been updated to 2008.

But if starting new ... please get 2008, it is free and much nicer.

ALSO, you will need to download and install the Windows platform SDK and Direct X SDK seperated from Visual C++ 2008 Express and also the free MSDN library. All of these are free, and after installing them you will have a decent / modern professional system set up for free.

Share this post


Link to post
Share on other sites
Quote:
Original post by mvBarracuda
Doesn't MSVC 2008 Express Edition already come with the platform SDK? AFAIR it was only a separate download for MSVC 2005 EE.

Yup it's even in the express FAQ page :)
# What types of application can I build with Visual C++ 2008 Express?

With Visual C++ 2008 Express you can build both native and managed applications. Included is the Windows Platform SDK which you can build applications that take full advantage of the Win32 API.
http://www.microsoft.com/express/support/faq/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this