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

当前回答

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

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

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

其他回答

许多问题都是由于缓存造成的,但您的问题是另一种困难的问题:命名事物。是的,本土化很难。

你没有提到你正在使用哪种法语变体,但从错误消息来看,我认为你正在使用“法语(法国)”(我们文明操作系统的用户称之为fr_FR)。MS的fr_FR语言环境以一种非常奇怪的方式表现:大写重音字母映射到它们的非重音对应字母(为了向后兼容某些型号的打字机)。因此您需要编写SORTIE_SUCCES而不是SORTIE_SUCCÈS。

A workaround is to use the “French (Monaco)” (fr_MC) language, where uppercase accented letters work as expected. Unfortunately, the Monaco version of the compiler is very very expensive. You could also use the Canadian French, Belgian French or Swiss French version, but these all require that you submit a bilingual (fr_CA + en_CA), trilingual (fr_BE + nl_BE + de_BE) or quadrilingual (fr_CH + it_CH + de_CH + rm_CH) source file. African variants of French are out because they are too poor to afford a C++ compiler, however you could use C instead.

那么在你的程序中还有其他语法错误:

你忘了翻译一些关键字。 注意,编译器和文档并不总是对同一个单词使用相同的翻译。 你没有解释法语中形容词都跟在名词后面。 你用错了引语类型。

我wollun尝试了Émaxe 510,70中包含的c++编译器中的以下代码,它wollun工作:

#inclure <fluxes>

principal ent(argn ent, argm **ent)  // entier, nombre d'arguments, valeur des arguments
{
   norme::sortiec << « Bonjour à tout le monde !\n » ;
   retourner SORTIE_SUCCÈS ;
}

有些语言具有比c++更好的国际化支持。例如,这是一个LOGO中的程序(当然不要与LOGO混淆)。

pour exemple
  répète 18 [av 5 td 10]
  td 60
  répète 18 [av 5 td 10]
fin

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

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

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

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

我知道这并不适用于这种特殊的情况,但在用法语编程时,记住对象的性别是很重要的。有2种类型的类(流派)流派::masculins和流派::féminin

例如:

genre::masculins Hommes {}
genre::féminin Femme {}

此外,当将this传递给另一个函数时,函数调用会以形参列表为前缀,而不是后缀:

genre::masculins Croissant {
    nul nourrir(Hommes hommes) {
        hommes.(ce)manger ;
    }
}

or

genre::féminin Grenouille {
    nul nourrir(Hommes hommes) {
        hommes.(cette)manger;
    }
}

进一步参考:维基百科词序

你好,轻跑进入轨道,

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

我建议以下几点:

#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的建议