Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C “外部”;";错误#2040:应为标识符_C_Hp Ux_Acc - Fatal编程技术网

C “外部”;";错误#2040:应为标识符

C “外部”;";错误#2040:应为标识符,c,hp-ux,acc,C,Hp Ux,Acc,我仍然在努力编译C控制台应用程序,编译过程仍然失败,错误如下: "Main.c", line 51: error #2040: expected an identifier extern "C" void TreatReceivedSignal( int NoSignal ) ; ^ 1 error detected in the compilation of "Main.c". gmake: *** [Main.o] Error 2 下面是C代码上extern方法的声明

我仍然在努力编译C控制台应用程序,编译过程仍然失败,错误如下:

"Main.c", line 51: error #2040: expected an identifier
  extern "C" void TreatReceivedSignal( int NoSignal ) ;
         ^
1 error detected in the compilation of "Main.c".
gmake: *** [Main.o] Error 2
下面是C代码上extern方法的声明:

extern "C" void TreatReceivedSignal( int NoSignal ) ;
我使用的是HP-UX aCC编译器[HP C/aC++B3910B A.06.26],我还打开了编译标志-Ae以启用C99支持。 似乎编译器无法将“extern“C”识别为C保留字,可能需要设置其他编译标志。 有什么办法可以解决这种问题吗? 事先非常感谢。 关于

< P> <代码>外部“C”< /C>结构是一个C++特定的东西,它不能在C.使用,编译器将源文件作为C源文件,因为它有扩展<代码> .c/c> > /p> <>最常用的方法是使用预处理器来为C++编译条件添加这个条件:

#ifdef __cplusplus
extern "C" {
#endif

/* Standard C prototypes */

#ifdef __cplusplus
}
#endif

据我所知,C和C++方法可以在这两种语言上使用链接mechanism@jamel你可以使用C++和C++的函数,它是编译器抱怨的<代码>外部“C”< /代码>。这个构造不是用C语言编写的。是的,我不知道为什么它是compaling,但是我用旧版本的aCC编译了同一个应用程序!此版本可能需要在编译过程中设置一些附加标志@C编译器jamel抱怨,因为您使用的构造不是C语言。这是简单的。))我会试着添加“γIFIFF”,而我将C发生什么,谢谢MANC和C++不一样。不要把他们当回事。要么学一个,要么学另一个。不要同时学习它们。不要为了“可编译为C++”而编写C代码。这是个坏主意的原因有很多。用C编写,或者用C++编写。如果你想把C代码链接到C++项目,用C编译器编译C代码,并用C++链接器链接目标代码。