Writing an MFC application using the C API

All of Total Phase's products include a royalty-free C API. While this article uses the Aardvark adapter's C API as an example, the same information can be applied to the C APIs for the Beagle analyzers and the Cheetah adapter.

The MSVC++ compiler has a feature which pre-compiles header files to speed up compilation time. The header file stdafx.h centralizes all the pre-compiled data into one place. Normally, MFC applications requires that #include "stdafx.h" be added to each source file that requires these headers.

The Aardvark API is not an MFC C++ library, and thus should not be precompiled. Therefore, the aardvark.h file should not be added to stdafx.h.

To specify that aardvark.h not be precompiled by Visual C++, do the following:

Using Visual Studio 6

  1. Add aardvark.c and aardvark.h to your Visual Studio project
  2. Go to Project | Settings...
  3. "Settings for" should show the project you are building
  4. Expand "Source Files" on the left
  5. Select "aardvark.c" by clicking once
  6. On the right, select the C/C++ tab
  7. In the "Category" box, select "Precompiled Headers"
  8. Select "Not using precompiled headers"
  9. Click OK to close the dialog

Using Visual Studio .NET

  1. Add aardvark.c and aardvark.h to your Visual Studio project
  2. Go to the "Solution Explorer" (Ctrl + Alt + L)
  3. Expand "Source Files"
  4. Right-click "aardvark.c"
  5. Select the "Properties" option
  6. In the "Configuration" drop-down box select "All configurations"
  7. Set the "Create/Use Precompiled Header" option to "Not using precompiled headers"
  8. Click OK to close the dialog

Now, simply add #include "aardvark.h" in any source file that requires the Aardvark API.