Sign in to follow this  

Problem with visual c++(Entirely unrelated to previous)

This topic is 4391 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Yes, I realize I am asking a lot fo damn questions today but I finally decided to switch to visual c++ , though I'm strongly considering going back to dev c++.... I go create project..we'll name it...grr (to represent my frustration). then I hit okay...then next...then I hit windows application... I also make it an empty project. finally I hit finish.. next I right click on source files, click add->new item and select c++ file and call it source2.cpp
/**************************************************
WinMain.cpp
Chapter 5 Stack Process Demo

Programming Role-Playing Games with DirectX
by Jim Adams (01 Jan 2002)
**************************************************/

// Include files
#include <windows.h>
#include <stdio.h>

class cProcessManager
{
  // A structure that stores a function pointer and linked list
  typedef struct sProcess {
    void  (*Function)();
    sProcess *Next;
  } sProcess;

  protected:
    sProcess *m_ProcessParent; // The top state in the stack
                               // (the head of the stack)

  public:
    cProcessManager() { m_ProcessParent = NULL; }

    ~cProcessManager() 
    {
      sProcess *ProcessPtr;

      // Remove all processes from the stack
      while((ProcessPtr = m_ProcessParent) != NULL) {
        m_ProcessParent = ProcessPtr->Next;
        delete ProcessPtr;
      }
    }

    // Add function on to the stack
    void Add(void (*Process)())
    {
      // Don't push a NULL value
      if(Process != NULL) {
        // Allocate a new process and push it on stack
        sProcess *ProcessPtr = new sProcess;
        ProcessPtr->Next = m_ProcessParent;
        m_ProcessParent = ProcessPtr;
        ProcessPtr->Function = Process;
      }
    }

    // Process all functions
    void Process()
    { 
      sProcess *ProcessPtr = m_ProcessParent;

      while(ProcessPtr != NULL) {
        ProcessPtr->Function();
        ProcessPtr = ProcessPtr->Next;
      }
    }
};

cProcessManager g_ProcessManager;

// Function prototypes
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev,                             LPSTR szCmdLine, int nCmdShow);

// Macro to ease the use of MessageBox function
#define MB(s) MessageBox(NULL, s, s, MB_OK);

// Processfunction prototypes - must follow this prototype!
void Func1() { MB("1"); }
void Func2() { MB("2"); }
void Func3() { MB("3"); }

int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev,                             LPSTR szCmdLine, int nCmdShow)
{
  g_ProcessManager.Add(Func1);
  g_ProcessManager.Add(Func2);
  g_ProcessManager.Add(Func3);
  g_ProcessManager.Process();
  g_ProcessManager.Process();

  return 0;
}


whenever I hit compile I get the error...
Quote:
c:\documents and settings\owner\my documents\visual studio 2005\projects\grr\grr\source2.cpp(10) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory Build log was saved at "file://c:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\grr\grr\Debug\BuildLog.htm" grr - 1 error(s), 0 warning(s)
which is saying it can't include the file windows.h, however it works fine on devc++ and microsoft visuall c++ 6.0 (student edition).... any ideas? and yes, at this point..i'll even take give up on visual c++ :-D

Share this post


Link to post
Share on other sites
It's not unrelated to the problem before. You still haven't added the platform SDK include directory to the search path. Which was part 3 of the instructions of using the Platform SDK with MSVC .NET 2005 Express Edition. Go to Tools->Options and add the directories.

Share this post


Link to post
Share on other sites
okay..i'm there.i'm looking at it..i see $(VCInstallDir)bin and the like...i even see a place to add a new line...however that syntax doesn't match theirs....

as a blind guess..under executable files i added the line.."C:\Program Files\Microsoft SDK\Bin" and so on and so forth for the other two under the appropriate header...
the line in corewin was all ready modified...i did the last step..still the same error...

Share this post


Link to post
Share on other sites
Hi, it seems you are using Visual C++ 2005 .NET Express Edition. To be able to compile Win32 native code, you need (as stated by MS) to install the Platform SDK. You can download it from the microsoft site. Once you have installed it you need to take a few more steps (editing some files).
Go check this link for instructions: http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/default.aspx

Hope it helps!

Share this post


Link to post
Share on other sites
Quote:
Original post by Charles256
i did the last step..still the same error...


You need to set the include path directy of the current project. So go to Project->Properties->C/C++ Tab (Configuration Properties Tab)->Additional Include Directories, then add in the "C:\Program Files\Microsoft SDK\Include". Now you will need to do the same thing for the library folder, "C:\Program Files\Microsoft SDK\Lib", which is under the Linker->General->Additional Linker Directories (~4th from bottom). That should fix it. This problem has come up a lot and that is the same thing I've told others and it worked for them as well as myself.

// Assuming this is the Express Edition

Share this post


Link to post
Share on other sites
Compiling...
source2.cpp
c:\documents and settings\owner\my documents\visual studio 2005\projects\grr\grr\source2.cpp(10) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
Build log was saved at "file://c:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\grr\grr\Debug\BuildLog.htm"
grr - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


still the same error..screw it.sorry to waste your guys time but there's no way I'm using this thing... does the professional edition have all this crap too? please tell me it's okay from the box.

Share this post


Link to post
Share on other sites
Quote:
Original post by Charles256
still the same error..


Open up the folder "C:\Program Files\Microsoft SDK\Include" and see if Windows.h is there. If it is, and you can see it and open it, then sorry, I have never heard of anything like this before. If it's not, find the real location of the file, and use that path instead. The same goes for the /Lib folder as well, look for a lot of .libs.

Oh and no, the non-express versions are all ready to of out of the box without any problems [wink]

Share this post


Link to post
Share on other sites
charles - In your 4 posts today you've called two well recommended books and a product from the industry standard of ide's crappy... the reasons seem to be that one book is too advanced, and the other book isn't working with the ide, which isn't working at all... Now sure, you may be having more problems getting things running than others have - but maybe a little more patience would be in order before calling 3 products (which work fine for thousands to millions of other people) crappy.

From the sounds of it things just aren't working for you with installing & configuring the psdk - so I won't give any more suggestions there. But maybe you should ask yourself why you switched away from dev-c++ in the first place? If you can't think of anything you don't like about that ide - and msvc++ is giving you all kinds of trouble, then there's definitely nothing wrong with switching back to dev-c++ - use whatever works best for you.

If you still want to work on getting msvc++ working, but you don't think you can get it done on your own, you may consider having someone else who already knows how to do it remote desktop into your machine, and do it for you - so you can watch and learn how to do it next time. If you want to do this but don't know anyone personally who could do this for you I'd be happy to get remote desktopping setup with you and walk you through the setup of the psdk & your c++ express projects. But again - this is only if you still want to get this working - there's nothing wrong with using dev-c++ if you'd prefer that.

Share this post


Link to post
Share on other sites
couchmonster-allow me to clarify. the one book..where is it... :: goes digging :: sams teach yourself game programming in twenty four hours has an error in it that prevents it from compiling and he didn't explain what was going on well enough for me to fix the error. I'm not saying it's unfixable, I'm just saying i copied and pasted his source code from the CD and it still didn't work...so I don't think I made the error... As for the other one about programming role playing games it's just too advanced. I'm not calling it crap, I'm saying it's just too advanced for me at the moment. and i still stand by the way I have tos et up visual c++ at the very least annoying and at the most down right crap:) and I switched because everyone says it's the best and my school recommends it but it was driving me batty earlier..on the bright side I did get it to compile..until it ran into a billion other errors which I'll post in a new thread since this one was for me trying to get the thing working (Even if I didn't realize it at first)

Share this post


Link to post
Share on other sites

This topic is 4391 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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