C and C++ don't mix, Something wrong with my header?

S

ssndk123

Hi,

I'm trying to include some C functions from IOPort.h/cpp to my C++
program.. i placed the IOPort.h into stdafx, but when I try to
compile i get the errors like: ioport.h(8) : error C2065: 'UINT' :
undeclared identifier. So, the Visual Studio 2005 compiler doesn't
know what UNIT is?

Am I doing something wrong? I attached my code below.

I'd appreciate any help..

Thanks,
Soren

-------------------------------------------------
stdafx.h:
-------------------------------------------------
#pragma once

#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP
or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to
target other versions of Windows.
#endif

#include <stdio.h>
#include <tchar.h>
#include "IOPort.h"

-----------------------------------------------
IOPort.h:
------------------------------------------------
#ifndef IOPORTH
#define IOPORTH

#ifdef __cplusplus
extern "C" {
#endif

void outport(UINT portid, UINT value);
void outportb(UINT portid, BYTE value);
BYTE inportb(UINT portid);
UINT inport(UINT portid);
BOOL StartUpIoPorts(UINT PortToAccess, BOOL bShowMessageBox, HWND
hParentWnd);

#ifdef __cplusplus
}
#endif

#endif

---------------------------------------------------
testmain:
----------------------------------------------------
#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
char i;
cout << "Hello World!!";
cin >> i;
return 0;
}
 
N

Noah Roberts

Hi,

I'm trying to include some C functions from IOPort.h/cpp to my C++
program.. i placed the IOPort.h into stdafx, but when I try to
compile i get the errors like: ioport.h(8) : error C2065: 'UINT' :
undeclared identifier. So, the Visual Studio 2005 compiler doesn't
know what UNIT is?

That's because it's declared in the windows.h header, or one that it
includes. Pretty sure anyway.

Make sure ioport.h is included after this. That will fix your immediate
problem. Then as was said, ask vc specific questions in a vc newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top