关于如何解决这个错误的任何想法

Any Ideas on how to fix this error?

本文关键字:任何想 错误 于如何 解决      更新时间:2023-10-16

当我试图在Unix服务器上编译我的c++代码时,我一直得到一个异常,但是这些行只有:

#ifndef WEIGHTED_GRAPH_H
#endif

,错误是:

In file included from Weighted_graph_tester.h:17,
                     from Weighted_graph_driver.cpp:18:
    Weighted_graph.h:1: error: stray â357â in program
    Weighted_graph.h:1: error: stray â273â in program
    Weighted_graph.h:1: error: stray â277â in program
    Weighted_graph.h:1: error: stray â#â in program
    In file included from Weighted_graph_tester.h:17,
                     from Weighted_graph_driver.cpp:18:
    Weighted_graph.h:172:2: error: #endif without #if
    Weighted_graph.h:1: error: âifndefâ does not name a type

任何想法?

它告诉您文件中有以下字节:

Oct: 357 273 277
Hex: EF  BB  BF

这些是UTF-8编码文件中的字节顺序标记。显然,编译器不支持开头有字节顺序标记的UTF-8源文件。实际上,在UTF-8文件中使用字节顺序标记是没有意义的,因为任何单个单元的大小都只有一个字节。你应该确保你保存了没有它的文件。

来自Unicode标准:

对于UTF-8,既不需要也不推荐使用BOM,但在使用BOM的其他编码形式转换UTF-8数据或将BOM用作UTF-8签名的上下文中可能会遇到。

相关文章: