如何解决“未识别的命令行选项”-std=gnu11“错误”?

时间:2022-02-10 23:19:09

I am planning to run a TCP client using C with Eclipse and here is the code. I added the output as well. Any ideas why I get the following output?

我计划运行一个使用C与Eclipse的TCP客户端,这是代码。我也添加了输出。知道为什么我得到下面的输出吗?

#include <winsock2.h>
#include <stdio.h>      /* for printf(), fprintf() */
#include <stdlib.h>     /* for exit() */

int main(int argc, char**argv)
{
   int sockfd,n;
   struct sockaddr_in servaddr,cliaddr;
   char sendline[1000];
   char recvline[1000];

   if (argc != 2)
   {
      printf("usage:  client <IP address>\n");
      exit(1);
   }

   sockfd=socket(AF_INET,SOCK_STREAM,0);

   bzero(&servaddr,sizeof(servaddr));
   servaddr.sin_family = AF_INET;
   servaddr.sin_addr.s_addr=inet_addr(argv[1]);
   servaddr.sin_port=htons(32000);

   connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));

   while (fgets(sendline, 10000,stdin) != NULL)
   {
      sendto(sockfd,sendline,strlen(sendline),0,
             (struct sockaddr *)&servaddr,sizeof(servaddr));
      n=recvfrom(sockfd,recvline,10000,0,NULL,NULL);
      recvline[n]=0;
      fputs(recvline,stdout);
   }
}
///////////////////////////////////////////////////////////////////////////////////

and here the output:

这里的输出:

*****11:25:59 **** Incremental Build of configuration Debug for project tcpcli ****
Info: Internal Builder is used for build
gcc -O0 -g3 -Wall -c -fmessage-length=0 -std=gnu11 -o tcpclient.o "..\\tcpclient.c" 
cc1.exe: error: unrecognized command line option '-std=gnu11'*****

1 个解决方案

#1


1  

I could finally manage to compile and run my codes in windows environment.

我终于可以在windows环境中编译和运行我的代码了。

gcc -v => gcc version 4.8.1 (GCC)

I used -std=gnu1x in C/C++ Build, Settings, Miscellaneous and in MinGW C Linker -> Libraries, I used wsock32 – mazkopolo

我使用了-std=gnu1x在C/ c++构建,设置,杂项和在MinGW C Linker ->库中,我使用wsock32 - mazkopolo。

#1


1  

I could finally manage to compile and run my codes in windows environment.

我终于可以在windows环境中编译和运行我的代码了。

gcc -v => gcc version 4.8.1 (GCC)

I used -std=gnu1x in C/C++ Build, Settings, Miscellaneous and in MinGW C Linker -> Libraries, I used wsock32 – mazkopolo

我使用了-std=gnu1x在C/ c++构建,设置,杂项和在MinGW C Linker ->库中,我使用wsock32 - mazkopolo。