C++ 为什么我的程序不能在 Windows 7 下用法语编译?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22780466/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why can't my program compile under Windows 7 in French?
提问by Lightness Races in Orbit
I'm running Windows 7 French and I'm trying to compile this really basic program, but Visual Studio is being stubborn and refuses to comply. I also tried compiling it with both GCC 4.7 and Clang trunk on Coliruand I get more or less the same errors (output is below the code), though I think Coliru runs on an English OS so I wouldn't expect it to work anyway.
我正在运行 Windows 7 法语,我正在尝试编译这个非常基本的程序,但 Visual Studio 很顽固,拒绝遵守。我还尝试在Coliru上使用 GCC 4.7 和 Clang 主干编译它,但我或多或少得到了相同的错误(输出在代码下方),尽管我认为 Coliru 在英文操作系统上运行,所以我不希望它能够正常工作.
What am I doing wrong? And how can I fix it?
我究竟做错了什么?我该如何解决?
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;
}
Output
输出
principal.cpp:1:6: erreur: prétraitement de la directive invalide #inclure
#inclure <iostream>
^
principal.cpp:6:8: erreur: '3' égaré dans le programme
renvoi SORTIE_SUCCèS;
^
principal.cpp:6:8: erreur: '0' é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
^
采纳答案by Gilles 'SO- stop being evil'
Many problems are due to caching, but yours is one of the other kind of hard problems: naming things. Yes, localization is hard.
许多问题是由于缓存造成的,但您的问题是另一种难题:命名事物。是的,本地化很难。
You didn't mention which variant of French you're using, but from the error message, I think you're using “French (France)” (what we users of civilized OSes call fr_FR
). MS's fr_FR
locale behaves in a very weird way: uppercase accented letters are mapped to their unaccented counterpart (for backward compatibility with some typewriter models). So you need to write SORTIE_SUCCES
instead of SORTIE_SUCCèS
.
您没有提到您使用的是哪种法语变体,但从错误消息中,我认为您使用的是“法语(法国)”(我们文明操作系统的用户所称的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.
一种解决方法是使用“法语(摩纳哥)”( fr_MC
) 语言,其中大写重音字母按预期工作。不幸的是,摩纳哥版本的编译器非常昂贵。您也可以使用加拿大法语、比利时法语或瑞士法语版本,但这些都要求您提交双语 ( fr_CA
+ en_CA
)、三语 ( fr_BE
+ nl_BE
+ de_BE
) 或四语( fr_CH
+ it_CH
+ de_CH
+ rm_CH
) 源文件。法语的非洲变体已经过时,因为它们太穷而无法负担 C++ 编译器,但是您可以改用 C。
Then there are other syntax errors in your program:
那么你的程序中还有其他语法错误:
- You forgot to translate some keywords.
- Beware that the compiler and the documentation don't always use the same translation for the same word.
- You didn't account for the fact that adjectives come after the noun in French.
- You're using the wrong type of quotes.
- 您忘记翻译一些关键字。
- 请注意,编译器和文档并不总是对同一个词使用相同的翻译。
- 你没有考虑到法语中形容词跟在名词之后的事实。
- 您使用了错误类型的引号。
I wollun tried the following code in the C++ compiler included in émaxe 51,70, and it wollun worked:
我 wollun 在 émaxe 51,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?;
}
Some languages have better internationalization support than C++. For example, here's a program in LOGO(not to be confused with LOGOof course).
有些语言比 C++ 有更好的国际化支持。例如,这里有一个LOGO 中的程序(当然不要与LOGO混淆)。
pour exemple
répète 18 [av 5 td 10]
td 60
répète 18 [av 5 td 10]
fin
回答by Martin J.
The problem is obviously that you are including the wrong standard header:
问题显然是您包含了错误的标准标题:
#inclure <iostream>
should be:
应该:
#inclure <fluxes>
Also, you'll find that this works much better is you use Studio Visuel Micromou or the CCG (stands for "Collection de Compilateurs GPU", btw) tools, rather than their more common MVS or GCC relatives.
此外,您会发现,如果您使用 Studio Visuel Micromou 或 CCG(代表“Collection de Compilateurs GPU”,顺便说一句)工具,而不是它们更常见的 MVS 或 GCC 相关工具,效果会更好。
回答by Angew is no longer proud of SO
You have a semantic error - the second argument of the entry function should be of type
cara**
, notent**
:ent principal(ent argn, cara** argm)
For the
<iostream>
error, @MartinJ. already correctly pointed out you should be using<esflux>
instead.Regarding the other errors, it seems your compiler is simply on strike. This can happen occasionally when compiling french code, and should fix itself in a few days.
你有一个语义错误 - 入口函数的第二个参数应该是 type
cara**
,而不是ent**
:ent principal(ent argn, cara** argm)
对于
<iostream>
错误,@MartinJ。已经正确指出你应该使用它<esflux>
。关于其他错误,您的编译器似乎正在罢工。编译法语代码时偶尔会发生这种情况,应该会在几天内自行修复。
回答by zmarties
I'm trying to compile this really basic program.
我正在尝试编译这个非常基本的程序。
This is not a BASIC program, so Visual Studio does not know what to do with it.
这不是 BASIC 程序,因此 Visual Studio 不知道如何处理它。
In addition, on a French system, you need to pass a programme to the compiler.
此外,在法语系统上,您需要将程序传递给编译器。
回答by Pierre Arlaud
Hello Légèreté fait la course en orbite,
你好Légèreté fait la course en Orbite,
I'd like to emphasize that even though you follow all the answers given here, your program still won't compile because of your punctuation. Semicolons are preceded by a non-breaking space in French.
我想强调的是,即使您遵循此处给出的所有答案,您的程序仍然无法编译,因为您的标点符号。在法语中,分号前面有一个不间断的空格。
I would recommend the following:
我会推荐以下内容:
#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?;
}
Please notice I changed argn
to narg
, as it is more natural in French (nothing to do with hungarian notations though)!
请注意我换argn
到narg
,因为它是更自然法语(没有与匈牙利命名法,虽然这样做)!
Edit: followed angew's recommendation
编辑:遵循angew的建议
回答by jwav
Pretty much everything's been covered in the previous answers, but if I may add:
前面的答案几乎涵盖了所有内容,但如果我可以添加:
renvoyer SORTIE_SUCCèS ; // correct, but bad pratice
this is certesallowed, but the following is usually preferred:
这的确允许的,但下面的通常优选:
capitulation ; // a better, frenchier approach
回答by pmartin
You need to reference the french pre-processor :
您需要参考法语预处理器:
#inclure <Montebourg>
hummm... too late, it is deprecated. The new release will be available this week.
嗯......为时已晚,它已被弃用。新版本将于本周发布。
回答by Chris Pfohl
I realize this doesn't apply to this particular situation, but it's important to keep in mind the gender of your objects when programming in French. There are 2 types of classes (genre
) genre::masculins
and genre::féminin
我意识到这不适用于这种特殊情况,但在用法语编程时记住对象的性别很重要。有两种类型的类 ( genre
)genre::masculins
和genre::féminin
For instance:
例如:
genre::masculins Hommes {}
genre::féminin Femme {}
Furthermore, when passing this
to another function the function call is prefixed with the parameter list rather than suffixed:
此外,当传递this
给另一个函数时,函数调用以参数列表为前缀而不是后缀:
genre::masculins Croissant {
nul nourrir(Hommes hommes) {
hommes.(ce)manger ;
}
}
or
或者
genre::féminin Grenouille {
nul nourrir(Hommes hommes) {
hommes.(cette)manger;
}
}
For further reference: Wikipedia Word Order
进一步参考:维基百科词序
回答by Sylvain Rodrigue
What if you retry after lunch hours (12-2 pm) ? Also, if you get more then one processors, they may be on strike. You can get your proc back however with this (French) Windows 7 command:
如果您在午餐时间(下午 12-2 点)后重试会怎样?此外,如果您获得不止一个处理器,它们可能会罢工。但是,您可以使用此(法语)Windows 7 命令恢复您的 proc:
set max-working-hours-a-week = 35
Repeat when you're stuck (but don't forget to lower the number each time!).
当你被卡住时重复(但不要忘记每次降低数字!)。
回答by Ferenc Deak
Seems you forgot to install the FrenChPP++
package. After a successful installation (you will need to compile FrenChPP++
on a standard c++ compiler if there are no binary packages for your system (we at the Unauthorized Frog recommend using g++ for this, but feel free to use clang too, but ignore the warnings)) you will need to create a new project, and just copy paste this into the newly created principal.fcpp
file. Then upon execution the FrenChPP++
precompiler (which works very similarly to the way Qt handles its signals/slot mechanism) will parse all .fcpp
files and will "translate" the .fcpp
into valid .cpp
and then compile them using your system default compiler.
似乎您忘记安装该FrenChPP++
软件包。成功安装后(FrenChPP++
如果您的系统没有二进制包,您将需要在标准 c++ 编译器上进行编译(我们在 Unauthorized Frog 建议为此使用 g++,但也可以随意使用 clang,但忽略警告))您需要创建一个新项目,然后将其复制粘贴到新创建的principal.fcpp
文件中。然后在执行时FrenChPP++
预编译器(其工作方式与 Qt 处理其信号/槽机制的方式非常相似)将解析所有.fcpp
文件并将其“翻译”.fcpp
为有效.cpp
,然后使用您的系统默认编译器编译它们。