相关疑难解决方法(0)

在Windows上使用sys/socket.h函数

我正在尝试在Windows中使用socket.h函数.基本上,我目前正在查看https://beej.us/guide/bgnet/html/multi/clientserver.html#datagram上的示例代码.我知道socket.h是一个Unix函数 - 无论如何我在编译这个示例代码时可以轻松地模拟该环境吗?不同的IDE /编译器会改变什么吗?

否则,我想我需要利用虚拟化的Linux环境,这可能是最好的,因为代码最有可能在UNIX环境中运行.

谢谢.

c sockets windows

28
推荐指数
1
解决办法
8万
查看次数

为什么GCC允许在C++中使用round(),即使使用ansi和pedantic标志?

有没有一个很好的理由为什么这个程序在GCC下编译,即使使用-ansi-pedantic标志?

#include <cmath>

int main (int argc, char *argv [])
{
     double x = 0.5;

     return static_cast<int>(round(x));
}
Run Code Online (Sandbox Code Playgroud)

用它来编译干净(没有警告,甚至)g++ -ansi -pedantic -Wall test.cpp -o test.

我看到两个问题:

  1. round() 在ISO-conformant模式下不应该对C++可用(因为它来自C99)
  2. 即使round()在这种情况下可用,它也应该只是std命名空间

我错了吗?

c++ gcc rounding c++98

6
推荐指数
1
解决办法
1704
查看次数

标签 统计

c ×1

c++ ×1

c++98 ×1

gcc ×1

rounding ×1

sockets ×1

windows ×1