什么是Windows相当于在sys / select.h和termios.h中定义的功能 [英] What is the Windows equivalent to the capabilities defined in sys/select.h and termios.h

查看:1043
本文介绍了什么是Windows相当于在sys / select.h和termios.h中定义的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在linux下的应用程序,这是成功编译。
我想在Windows中运行相同的程序。

I have an application in linux, which is compiled successfully. I want to run the same program in windows.

不过,编译产于头文件相关的以下错误。

But compilation produces the following errors related to header files.


  1. 找不到SYS / select.h

  2. 找不到termios.h

我该如何解决这个问题?

How can I fix this?

推荐答案

在Windows API在结构上和风格上非常从任何Unix味道提供的系统调用和库例程的混合不同。

The Windows API is structurally and stylistically very different from the blend of system calls and library routines provided by any flavor of Unix.

Windows那样终端I / O与任何的* nix系统中一个非常不同的模式。这样一来,真的是没有直接等同于 termio.h中头和它的朋友们。

Windows does terminal I/O with a very different model from any *nix system. As a result, there really is no direct equivalent to the termio.h header and its friends.

您想在MSDN有关Windows 通信资源阅读

You want to read at MSDN about the Windows Communications Resources.

有些事情要了解包括:

在一般情况下,你会发现,你需要处理更大量的Windows API直接,因为 STDIO 操作设备时,会增加混乱I / O。

In general, you will find that you need to deal a lot more with the Windows API directly because stdio will add to the confusion when doing device I/O.

有不是直接等同于Unix的选择(2)系统调用。

There isn't a direct equivalent to the Unix select(2) system call.

在Windows中,许多内核对象可以在任何一个信号或无信号状态,和信令对象的行为可以被用来释放一个线程调用<一个href=\"http://msdn.microsoft.com/en-us/library/ms687025%28VS.85%29.aspx\"><$c$c>WaitForMultipleObjects().当数据可用一些但不是所有 HANDLE 对象发出信号。具体来说,我知道 HANDLE 期从的WinSock有本事,但我不知道的通信API。我知道, HANDLE s到一个打开的文件则没有。

In Windows, many kernel objects can be in either a signaled or non-signaled state, and the act of signalling the object can be used to release a thread that called WaitForMultipleObjects(). Some but not all HANDLE objects are signaled when data is available. Specifically, I know that HANDLEs from WinSock have that capability, but I don't know about the Comm API. I know that HANDLEs to an open file do not.

如果您需要等待一个线程的事件正在处理窗口消息,那么你或许应该使用<一个href=\"http://msdn.microsoft.com/en-us/library/ms684242%28VS.85%29.aspx\"><$c$c>MsgWaitForMultipleObjects()相反,因为它正确传送邮件,而线程被阻塞,否则

If you need to wait for an event in a thread that is processing window messages, then you should probably use MsgWaitForMultipleObjects() instead, since it will properly deliver messages while the thread is otherwise blocked.

阅读在MSDN文章使用同步。

然而,有几种异步I / O内置在Windows中,可以通过设计变更取代需要选择()。双方将需要大量使用,不能在组合与C stdio库使用的功能。

However, there are several kinds of asynchronous I/O built into Windows that can replace the need for select() by a change of design. Both will require extensive use of features that cannot be used in combination with the C stdio library.

MSDN对I / O技术的几篇文章,以及众多的例子:

MSDN has several articles on I/O techniques, as well as numerous examples:

请注意,许多在Windows工作原理被散射概述文章和参考材料的讲话部分用于API的功能和结构中的信息。这可以使IM pression,没有什么是完全在一读记录。

Note that much of the information on how Windows works is scattered among the overview articles and the remarks sections of the reference material for the API functions and structures. This can give the impression that nothing is completely documented on a first reading.

另一种方法是使用 Cygwin的以做的端口。它提供了Windows API的一个最POSIX层。然而,你将最终的应用程序是依赖于Cygwin的DLL这是GPL,除非你从他们那里购买的商业使用许可。它可能会非常棘手使用Cygwin来获取对于没有任何Unix的经验也是一个Windows用户运行良好的应用程序,因为对两个系统的设置和使用不同的方式很多其他假设。

Another approach is to use Cygwin to do the port. It provides most of a POSIX layer over the Windows API. However, you will end up with an application that is dependent on the Cygwin DLL which is GPL unless you purchase a commercial use license from them. It can be tricky to use Cygwin to get an application that works well for a Windows user with no Unix experience also, since so many other assumptions about the way the two systems are setup and used differ.

Cygwin的做繁重相当数量的建的实施选择()上给予不同的打开文件描述符的混合Windows上运行。这项努力在用户指南描述。

Cygwin has done a fair amount of heavy lifting to build an implementation of select() that works on Windows given a mix of different open file descriptors. This effort is described in the User's Guide.

请注意,对建设Cygwin的,如果在Cygwin环境中完成的仅文档和支持。它通常是不够的只是把Cygwin的bin在Windows路径和工作从命令提示符。你真的需要启动的bash的Cygwin的建设,并从那里让一切都使用相同的Cygwin式挂载点和模拟Unix文件结构。

Do be aware that building against Cygwin is only documented and supported if done from within the Cygwin environment. It usually is not sufficient to just put Cygwin's bin on the Windows PATH and work from a command prompt. You really need to launch Cygwin's build of bash and compile from there so that everything is using the same Cygwin-style mount points and simulated Unix file structure.

混合使用第三方工具头文件Cygwin的头文件是到了疯狂一个肯定的路径。

Mixing Cygwin header files with third-party tool header files is a sure path to madness.

编辑:我已经重新安排了一下,并针对意见增加了一些材料

I've rearranged a bit, and added some material in response to comments.

这篇关于什么是Windows相当于在sys / select.h和termios.h中定义的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆