Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I Create 5 functions but undeclare variable

Status
Not open for further replies.

youssef

Programmer
Mar 13, 2001
96
BE
Hi,

I would like to create 5 functions :

- SERIALPORT_OPEN (I use hPort = CreateFile);
- SERIALPORT_CLOSE (I use CloseHandle(hPort));
- SERIALPORT_READDATA(I use ReadFile(hPort));
- SERIALPORT_WRITEDATA(I use WriteFile(hPort));

But when I compile the 5 functions, I have a problem.
The compile say that the hport is undeclared.

How can I do to use my functions ?
 
The problem is :

I use HANDLE hPort and I declare it in SERIALPORT_OPEN function.
But when I compile the other functions say hPort undeclared.
 
Well if you declare it within a function, it won't be able to be accessed by other functions. Its scope would only be the one function
 
but how can I do ?

May be declare it as a public variable in my class.
 
It also doesn't have to be public if its only used within the class. A private variable can be accessed by all members in a class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top