• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 621
  • Last Modified:

mfc project - problems with header files

I have a MFC project I'm developing to use for a Labjack data-acquisition card. I had it to compile at one time but when I added some files to include I keep getting errors. I'm not sure whether to put the include statements in the cpp or the header files. There's too much code to list here so I have the zip file on my website:

labjack application
  • 2
1 Solution
Hi zliminator,

could you first simply post the part of the ouput where the first errors occur?

The link to the ZIP file seems to be dead ...

zliminatorAuthor Commented:
I don't know if I copied the link wrong but it should work. Here it is without the link:


Here it is with the link:

ok, there are several problems in the code.

First, the main problem is the file "labjackocx.h" includes "data.h" which itself again includes "labjackocx.h". The way you designed the classes (CData uses a CLabJackOCX and CLabJackOCX uses a CData) isn't possible this way. You can only solve this by using a forward declaration for one of these classes, i.e.: instead of including "data.h" in "labjackocx.h" simply add this forward declaration befor the definition of CLabJackOCX:

    class CData;

Further problems are:

Some header files are included more than once producing 'class type redifintion' errors. You should add a '#pragma once' as first lines in these headers:

In some files the class CLabjackApp3Dlg is undefinded, so you need to add '#include "LabjackApp3Dlg.h"' in these files:

In 'data-h' you include 'stdafx.h' which is either useless (since it's already included everywhere you include 'data.h') and not recommended (since 'stdafx.h' has a very special role regarding precompiled headers) - you should remove this.

In 'config.h' you include 'afxwin.h'. This is useless since it is already included via 'stdafx.h', you should remove this.

I hope I didn't miss anything.

Hope that helps,

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now