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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read() write() commands, C to C++, header file to include? 1

Status
Not open for further replies.

pdecker

Technical User
Jun 16, 2003
31
0
0
US
Hi,

We are using write(file_descriptor, Ascii string, size of string) to write to a serial port in linux "/dev/ttyS0"

It works fine in C. However, we are trying to combine some code that is written in C++, and the only problem we have is that these two functions , read() and write(), dont seem to translate directly over. In C no header files are needed to use them, however when compiling in C++ it doesnt know what the functions are, so I assume there might be a header file out there that we need to include that has these functions defined? If so can someone tell me what it is? Thanks in advance...

Or , are there equivelent functions in C++? (we would like to still use the ones we have so we dont have to change code)
 
> In C no header files are needed to use them

Maybe, but then you don't have the header that prototypes them, so you could use them incorrectly & never get a compiler error. You should still include the header in your C files even if your compiler doesn't scream.

The header is unistd.h

Good Luck.
 
Thats it! Thank you very much. I will make sure we include that header from now on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top