Hello everybody,

I am trying to communicate with a Vitamin Scanner from a computer, which connects via Comm port. It should do the equivalent thing of opening up 'Hyper Terminal', typing in 'a', hitting enter, then typing in '?I', enter, 'S', enter, and a long list of integers shows up on the GUI.

So far, I have stumbled upon some code that by all means, should work. I have attached the code in a file attachment, along with a few header files that are important. I have also attached my Build Log in a screen shot, BuildLog.jpg.

I am using Visual C++ 2008 Express Edition. I use Windows XP. I try to compile, it says:

fatal error C1189: #error : include 'stdafx.h' before including this file for PCH

Please help me, I am stuck.

Attached Files:
http://lbpages.heliohost.org/BuildLog.jpg
See the others on the bottom.

Recommended Answers

All 4 Replies

There are a couple of things that are standing in the way of this compiling.
When you posted last I assumed incorrectly that this would be a console application. Upon a closer look it appears to be an MFC (MS Foundation Classes) application which is not directly supported by the express edition of VC++ only the standard.
In addition to that, the project seems to be missing some of the components, in particular the dialog resources (to what extent they can be regenerated I'm not sure).
That error message you were getting was coded into one of the header files to make sure that stdafx.h was included before that particular header file. In the stdafx.h that I generated with a Win32 project in VC++ express that value was not defined, which again may be a result of needing MFC, but I am not 100% on that.

Others more steeped in MFC might be able to advise you on how you can finagle this code back into Win32 or might be able to suggest a means through which you can access the serial port with the API.

So does anyone know of how I should edit stdafx.h to get his program to work?

So does anyone know of how I should edit stdafx.h to get his program to work?

Unfortunately editing stdafx.h will do no good. It is a MFC program you have there, and the VC Express won't be able to compile it like jonsca ^said^.
If you know someone, who's familiar with the MFC, the program might be quickly converted to a Win 32 GUI application, after all it appears to be a small'ish dialog-based program.

which code is then use in place of stdafx.h

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.