"-6ren"> "-我对 Linux 编程还很陌生。我正在使用 g++ 编译一个简单的 C++ 代码: #include“recip.hpp” #include double recip (int i) { // I s-6ren">
gpt4 book ai didi

c++ - 错误 - 编译 g++ 文件时出现 "#include expects "FILENAME"or "

转载 作者:塔克拉玛干 更新时间:2023-11-03 08:19:32 24 4
gpt4 key购买 nike

我对 Linux 编程还很陌生。我正在使用 g++ 编译一个简单的 C++ 代码:

#include“recip.hpp”
#include<cassert>

double recip (int i) {
// I should be non-zero.
assert (i != 0);
return 1.0/i;
}

文件 recip.hpp 存在于我的当前目录中。我不明白为什么会出现错误:

recip.cpp:1:9: error: #include expects "FILENAME" or <FILENAME>

怎么了?

最佳答案

编译器不是文本编辑器,也不是人类 - 它检查精确的字符代码匹配,而不是视觉相似性......你必须使用

#include "recip.hpp"

使用标准双引号。

关于c++ - 错误 - 编译 g++ 文件时出现 "#include expects "FILENAME"or <FILENAME>",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12336573/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com