error: stray '\XXX' in program : Why?

后端 未结 4 993
旧时难觅i
旧时难觅i 2020-12-17 16:47

I\'m writing a little program in C++, and come across a strange error :

src/Makefile/Tool.cpp:42:3: error: stray ‘\\302’ in program
src/Makefile/Tool.cpp:42         


        
4条回答
  •  难免孤独
    2020-12-17 17:48

    As aforementioned it is due to some not visible characters in your source. One great solution for this is to edit your file in octal mode and you will be able "to see" these characters:

    od -c MyClass.hpp
    

    Then you can see in the octal flow the "strangers" :

    0001240   t       s   t   r   i   n   g   &       n   a   m   e       )
    0001260       { **302 240**   t   h   i   s   -   >   n   a   m   e       =
    0001300       n   a   m   e   ;       }  \n  \n  \n  \t  \t  \t  \t   /
    

    This two characters in bold are the cause of messages like

    error: stray ‘\302’ in program 
    

    You can then remove them, and rebuild.

    Regards.

提交回复
热议问题