Hello everybody,

For a project my dad has enlisted me in, I am to be able to communicate with a Vitamin Scanner from a computer. To illustrate, he opened 'Hyper Terminal' (should come with most Windows computers). He set up a communication using the program, and told me the baudrate, stop bits, parity, etc.

So I set about making this program. I decided to use C++. After researching for like a week or so, I 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 am using Visual C++ 2008 Express Edition. I use Windows XP. When I try to compile, it says it can't find the header file "stdafx.h". Does anybody know where I can download it, and its associated files? Or, if there is no way to download it, does anybody know of a better way for Serial Communication in windows?

Recommended Answers

All 4 Replies

Start a new project in VC++ this time uncheck precompiled headers and leave empty project unchecked. Add your files to the project by right clicking on the solution/Add.. etc. and you can clear out all the other files (or just exclude them from the project to be safe). You've probably done everything correctly except for the precompiled headers part.

Ok , that fixed some probs, but I've now got another, in ADRTest.h, the file from above...
Here is the build log, the project is called ST2000, and the source file is ST.cpp.

Build Log Build started: Project: ST2000, Configuration: Debug|Win32
Command Lines Creating temporary file "c:\Documents and Settings\Bergeson\My Documents\Visual Studio 2008\Projects\ST2000\ST2000\Debug\RSP00000427523280.rsp" with contents
[
/Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /c /ZI /TP ".\ST.cpp"
]
Creating command line "cl.exe @"c:\Documents and Settings\Bergeson\My Documents\Visual Studio 2008\Projects\ST2000\ST2000\Debug\RSP00000427523280.rsp" /nologo /errorReport:prompt"
Output Window Compiling...
ST.cpp
c:\documents and settings\bergeson\my documents\visual studio 2008\projects\st2000\st2000\adrtest.h(12) : fatal error C1189: #error : include 'stdafx.h' before including this file for PCH
Results Build log was saved at "file://c:\Documents and Settings\Bergeson\My Documents\Visual Studio 2008\Projects\ST2000\ST2000\Debug\BuildLog.htm"
ST2000 - 1 error(s), 0 warning(s)

Turn off UNICODE -- goto Project --> Properties (the last menu item) -->Configuration Properties --> General. Now on the right side, the third item from the bottom is "Character Set". Change that setting to "Not Set"

You could have turned off precompiled headers in a similar way, except under Configuration Properties --> C/C++ --> Precompiled Headers.

My problems still there after I did what you said, Ancient Dragon

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.