Dylan
Dylan

Reputation: 31

Any Ideas on how to fix this error?

I keep getting the an exception when I attempt to compile my C++ code on a Unix server, but those lines just have:

#ifndef WEIGHTED_GRAPH_H
#endif

and the error is:

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

Any Ideas?

Upvotes: 1

Views: 3549

Answers (1)

Joseph Mansfield
Joseph Mansfield

Reputation: 110748

It's telling you that you have the following bytes in your file:

Oct: 357 273 277
Hex: EF  BB  BF

These are the byte order mark in UTF-8 encoded files. Obviously your compiler does not support UTF-8 source files with the byte order mark at the beginning of them. In fact, it doesn't even make sense to have the byte order mark in a UTF-8 file since any single unit is only a byte in size. You should make sure that you save the file without it.

From the Unicode Standard:

Use of a BOM is neither required nor recommended for UTF-8, but may be encountered in contexts where UTF-8 data is converted from other encoding forms that use a BOM or where the BOM is used as a UTF-8 signature.

Upvotes: 5

Related Questions