我正在运行Windows 7法语,我试图编译这个真正基本的程序,但Visual Studio是固执的,拒绝遵守。我也尝试在Coliru上用GCC 4.7和Clang trunk编译它,我得到或多或少相同的错误(输出在代码下面),尽管我认为Coliru运行在英语操作系统上,所以我不期望它无论如何都能工作。

我做错了什么?我该怎么解决呢?

Code

#inclure <iostream>

ent principal(ent argn, ent** argm)  // entier, nombre d'arguments, valeur des arguments
{
   std::cendehors << "Bonjour le monde!\n";
   renvoi SORTIE_SUCCÈS;
}

输出

principal.cpp:1:6: erreur: prétraitement de la directive invalide #inclure
     #inclure <iostream>
      ^
principal.cpp:6:8: erreur: '\303' égaré dans le programme
        renvoi SORTIE_SUCCÈS;
        ^
principal.cpp:6:8: erreur: '\210' égaré dans le programme
principal.cpp:3:5: erreur: «ent» ne désigne pas un type
     ent principal(ent argn, ent** argm)  // entier, nombre d'arguments, value des arguments
     ^

当前回答

之前的答案几乎涵盖了所有内容,但如果我可以补充一句:

renvoyer SORTIE_SUCCÈS ; // correct, but bad pratice

这当然是允许的,但以下通常是首选:

capitulation ; // a better, frenchier approach

其他回答

你有一个语义错误——入口函数的第二个参数应该是cara**类型,而不是ent**类型: Ent principal(Ent argn, cara** argm) 对于<iostream>错误,@MartinJ。已经正确指出,您应该使用<esflux>代替。 至于其他错误,似乎你的编译器只是在罢工。在编译法语代码时偶尔会发生这种情况,应该会在几天内自行修复。

在c++(或C)程序中不能使用法语关键字。你应该编写代码

 #include <iostream>
 //  ^^^  the english word "include" 

同样的

 return EXIT_SUCCESS;

当然,代码int main(int argc, char**argv)等…

(谢谢你愚人节的玩笑!)

你的代码中有这么多错误,其中大多数已经在其他答案中解决了。但你不知道c++的创造者设计它是为了让程序源代码在翻译时不会太长吗?

它不是std::cendehors,而是std::deh (dehors的缩写),因为std::cin翻译为std::ded (dedeans)。

还请注意,过去有编译器不会自动刷新\n,所以最好使用std::findl (fin de ligne)。所以应该是这样的:

   std::deh << "Bonjour le monde!" << std::findl; 

编辑:对不起,我没有发现另一个错误。正确的形式当然是使用这样的guillemets:

   std::deh << «Bonjour le monde!» << std::findl; 

你需要引用法语预处理器:

#inclure <Montebourg>

嗯……太晚了,它已被弃用。新版本将于本周发布。

我正在编译这个非常基本的程序。

这不是一个BASIC程序,所以Visual Studio不知道用它做什么。

此外,在法语系统上,需要将程序传递给编译器。