我正在运行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
     ^

当前回答

你好,轻跑进入轨道,

我要强调的是,即使您遵循了这里给出的所有答案,由于标点符号的存在,您的程序仍然无法编译。在法语中,分号前面有一个不间断的空格。

我建议以下几点:

#inclure <esflux>

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

请注意,我把argn改成了narg,因为它在法语中更自然(尽管与匈牙利符号无关)!

编辑:遵循angew的建议

其他回答

你有一个语义错误——入口函数的第二个参数应该是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)等…

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

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

#inclure <Montebourg>

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

你的代码中有这么多错误,其中大多数已经在其他答案中解决了。但你不知道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 <iostream>

应该是:

#inclure <fluxes>

此外,你会发现,如果你使用Studio visual Micromou或CCG(代表“Collection de Compilateurs GPU”,顺便说一下)工具,而不是它们更常见的MVS或GCC亲戚,效果会更好。