VxWorks默认的注释类型是"/* ...... */", 在使用C++类型的注释"//",就有可能报错。

一种方法是移除-ansi开关。可是怎么移除呢?对许多对编译器不太了解的人可能看了FAQ了不知道怎么办。下面具体讲解:

在VxWorks的工程里有build这个选项,字体变黑的就是你选的编译类型,以default为例,双击default(默认的),在c/c++compiler和assember里将-ansi去掉,保存就OK了!

下面来自预编译器文档'-lang-c', '-lang-c89', '-lang-c++', '-lang-objc', '-lang-objc++', specify the source language.

  • `-lang-c' is the default; it allows recognition of C++ comments (comments that begin with '//' and end at end of line), since this is a common feature and it will most likely be in the next C standard.
  • '-lang-c89' disables recognition of C++ comments.
  • '-lang-c++' handles C++ comment syntax and includes extra default include directories for C++.
  • '-lang-objc' enables the Objective C '#import' directive.
  • '-lang-objc++' enables both C++ and Objective C extensions.

These options are generated by the compiler driver gcc, but not passed from the 'gcc' command line unless you use the driver's `-Wp' option.

其实如果要跟深入了解,可以看看GNU方面的资料,另外,在.cpp格式的文件中可以使用//做注释,编译不会报错。