对于我使用的Windows,是否有跨平台解决方案来获得自纪元以来的秒数
long long NativesGetTimeInSeconds()
{
return time (NULL);
}
Run Code Online (Sandbox Code Playgroud)
但是如何上Linux呢?
是否存在超时交叉平台soulution以接受客户端使用accept功能而无需将套接字设置为非阻塞?
我知道我应该使用select它的功能,但我做错了什么?
SOCKET NativesAcceptClient(SOCKET s, int timeout)
{
int iResult;
struct timeval tv;
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(s, &rfds);
tv.tv_sec = (long)timeout;
tv.tv_usec = 0;
iResult = select(s, &rfds, (fd_set *) 0, (fd_set *) 0, &tv);
if(iResult > 0)
{
return accept(s, NULL, NULL);
}
else
{
//always here, even if i connect from another application
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
如何解决?谢谢!
我在cygwin上安装crosstool-ng时遇到问题.
我已经下载了最后包这里以root cygwin的文件夹,然后:
完整的错误日志:
$ make
SED 'ct-ng'
SED 'scripts/crosstool-NG.sh'
SED 'scripts/saveSample.sh'
SED 'scripts/showTuple.sh'
GEN 'config/configure.in'
GEN 'paths.mk'
GEN 'paths.sh'
LD 'conf'
zconf.tab.o:zconf.tab.c:(.text+0x1799): undefined reference to `_libintl_gettext'
zconf.tab.o:zconf.tab.c:(.text+0x48f8): undefined reference to `_libintl_gettext'
zconf.tab.o:zconf.tab.c:(.text+0x592b): undefined reference to `_libintl_gettext'
zconf.tab.o:zconf.tab.c:(.text+0x5b20): undefined reference to `_libintl_gettext'
zconf.tab.o:zconf.tab.c:(.text+0xcd60): undefined reference to `_libintl_gettext'
zconf.tab.o:zconf.tab.c:(.text+0xcd6e): more undefined references to `_libintl_gettext' follow
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: zconf.tab.o: bad reloc address 0x564 in section `.data'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: final link failed: Invalid operation
collect2: ld returned …Run Code Online (Sandbox Code Playgroud) 我有一个std::string,我该如何替换:字符%%?
std::replace( s.begin(), s.end(), ':', '%%' );
上面的代码不起作用:
错误没有实例匹配争论列表
谢谢!