473,383 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

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;
}

Jun 27 '08 #1
2 3370
ss******@gmail.com wrote:
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?
No compiler knows what "UINT" (or "UNIT") is, unless you tell them.
If you expect 'UINT' ('UNIT') to play a role of a type, you need to
include a header (most likely) that has the 'typedef' in it or do
it yourself, like so

typedef unsigned UINT;
>
Am I doing something wrong? I attached my code below.
Your code contains too much compiler-specific elements, perhaps the
'microsoft.public.vc.language' newsgroup is a better place to ask?
>
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;
}
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #2
ss******@gmail.com wrote:
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.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

40
by: komone | last post by:
"Now is the time for all good web developers to use stylesheets". Hmm OK, so I start this commercial site design with the express intent of using CSS entirely. (Something I haven't attempted in...
23
by: Carter Smith | last post by:
http://www.icarusindie.com/Literature/ebooks/ Rather than advocating wasting money on expensive books for beginners, here's my collection of ebooks that have been made freely available on-line...
28
by: Xiaotian Sun | last post by:
I added the following line to the header of my html file <meta http-equiv="content-type" content="text/html; charset=utf-8"> hoping browsers will use UTF-8 encoding. But all browsers I tried...
15
by: jiverbean | last post by:
Dear group members, I cam across a glitch in Javascript and I don't know how to solve it elegantly. I have an array with strings of German words: profile = "Fröhliches Fräulein"; Because...
9
by: David. E. Goble | last post by:
Arrrh! some buttons work while others don't, but I can't see why. I have tried comparing the files that do work, with the ones that don't. But to no help. The funny thing is the parts that work...
19
by: LP | last post by:
I am using (trying to) CR version XI, cascading parameters feature works it asks user to enter params. But if page is resubmitted. It prompts for params again. I did set...
20
by: Tony | last post by:
I have a situation where I want to send data, but I have no need for a response. It seems to me that XMLHTTPRequest is the best way to send the data, but I don't need any response back from the...
3
by: smorrey | last post by:
Howdy folks, I recently purchased a book on C++ MUD creation and it features alot of nifty tidbits. The book is MUD GAME PROGRAMMING by Ron Penton Publisher: Premier Press Anyways of...
2
hsriat
by: hsriat | last post by:
I am not sure how many of you would have faced this problem, but I faced this many times. I am not good at memorizing things, so I give lot of code comment in my code. And never wanted that code to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.