如何使用模块TS和GCC编译C ++代码(实验性)? [英] How to compile C++ code using modules-ts and gcc (experimental)?

查看:51
本文介绍了如何使用模块TS和GCC编译C ++代码(实验性)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用c ++ 20中将包含的新实验性功能"modules-ts"进行编码.我已经克隆了gcc分支(在这里找到: https://gcc.gnu.org/wiki/cxx-modules ),而我正在尝试使用modules-ts(在链接上)遵循该教程,但g ++错误阻止了我这样做:

I've been trying to code something using the new experimental feature "modules-ts" that will be included in c++20. I've cloned the gcc branch (found here: https://gcc.gnu.org/wiki/cxx-modules), and I'm trying to follow that tutorial (on the link) using modules-ts but an g++ error is preventing me from doing that:

g ++:错误:无法识别的命令行选项"-fmodules-ts"

g++: error: unrecognized command-line option ‘-fmodules-ts’

我试图查看g ++的版本,以确保未从其他先前版本中读取该版本.答案是:

I tried to see the version of g++, to make sure that is not reading from another previous version. And the answer is:

g ++(GCC)10.0.0 20191029(实验性)版权所有(C)2019自由软件基金会,Inc.这是免费软件;请参阅复制条件的来源.没有保修单;甚至不是出于适销性或针对特定目的的适用性.

g++ (GCC) 10.0.0 20191029 (experimental) Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

这是我要运行的命令:

g ++ -fmodules-ts hello.cppm main.cpp

g++ -fmodules-ts hello.cppm main.cpp

推荐答案

Modules-ts尚未合并到GCC的主分支中.您需要下载GCC的源代码并自己进行编译,有关更多说明,请参见 GCC的安装指南.使用

Modules-ts is not merged into GCC's main branch yet. You need to download GCC's source and compile it yourself, for further instructions see GCC's installation guide. Grab the source using

svn co svn://gcc.gnu.org/svn/gcc/branches/c++-modules SomeLocalDir

代替

svn checkout svn://gcc.gnu.org/svn/gcc/trunk SomeLocalDir

您将获得正确的版本.

为了澄清起见,在此答案中,我假定OP未能编译正确的GCC版本,因为他的gcc --version中没有svn修订版号.

For clarification, in this answer I assumed the OP did not compile the right GCC version because there is no svn revision number inside his gcc --version.

这篇关于如何使用模块TS和GCC编译C ++代码(实验性)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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