http://stackoverflow.com/questions/9099892/how-to-use-tformatsettings-create-without-being-specific-to-a-platform

 

I have the following in Delphi XE:

fSettings := TFormatSettings.Create(LOCALE_USER_DEFAULT);

But I always get a warning on compile:

W1002 Symbol 'Create' is specific to a platform

What is the correct way to do this, so that I do not get a warning?

asked Feb 1 '12 at 16:57
croceldon
1,05532149
 

3 Answers

You have two options 你有2个选择

1) Use the overload version which uses a string instead of a TLocaleID 使用一个具体的LCID字符串

class function Create(const LocaleName: string): TFormatSettings; overload; static;

2) Disable the warning locally 临时禁用 这个Warn 编译器开关。

{$WARN SYMBOL_PLATFORM OFF}
fSettings := TFormatSettings.Create(LOCALE_USER_DEFAULT);
{$WARN SYMBOL_PLATFORM ON}
answered Feb 1 '12 at 17:15
RRUZ
102k8204353
 
5  
Option 3. Disable the warning globally. If you never build for platforms other than Windows, there's not much point in enabling it at all. –  David Heffernan Feb 1 '12 at 17:20 如果你 从来不 开发 Windows平台以外的软件,直接全局关闭这个 Warn
    
If I choose to use the string version, what is the string that is equivalent to LOCALE_USER_DEFAULT? – croceldon Feb 1 '12 at 18:49
    
try using an empty string or the constructor without parameters, this will call the GetThreadLocale function internally. just be careful with the calls to SetThreadLocale because can change the result of this function. –  RRUZ Feb 1 '12 at 18:59
 

My code is now written as follows:

{$IFDEF VER220}
FormatSettings := TFormatSettings.Create(GetThreadLocale);
{$ELSE}
GetLocaleFormatSettings(GetThreadLocale, FormatSettings);
{$ENDIF}

You will probably want to adjust that IFDEF for appropriate future versions, but it gives the idea.

answered Feb 1 '12 at 17:52
mj2008
4,89711947
 
    
This snippet actually is by magnitude more specific to platform than which compiler complains about. – OnTheFly Feb 1 '12 at 18:43
    
@user539484 Perhaps, but IIRC I got it from the help as the recommended way. –  mj2008 Feb 2 '12 at 9:29

There are different overloads of TFormatSettings.Create. The one with an LCID is specific to Windows. The one without any parameters and the one taking a locale name as a string are more portable.

Or you could suppress the warning for platform-specific units and procedures, if you know your software will never be used for anything other than Delphi for Windows. The VCL contains traces of now unsupported platforms such as Linux (Kylix) and .NET (Delphi.NET), and since they're as dead as can be, making your code portable to those platforms may be a waste of time.

answered Feb 1 '12 at 17:09
hvd
51.9k677123

W1002 Symbol 'Create' is specific to a platform的更多相关文章

  1. Delphi Waring 的信息

    Display PreferencesWarning messages (Delphi)Go Up to Delphi Compiler Directives (List) Index TypeSwi ...

  2. Delphi DLL制作和加载 Static, Dynamic, Delayed 以及 Shared-Memory Manager

    一 Dll的制作一般分为以下几步:1 在一个DLL工程里写一个过程或函数2 写一个Exports关键字,在其下写过程的名称.不用写参数和调用后缀.二 参数传递1 参数类型最好与window C++的参 ...

  3. Android Studio 项目中集成百度地图SDK报Native method not found: com.baidu.platform.comjni.map.commonmemcache.JNICommonMemCache.Create:()I错误

    Android Studio 项目中集成百度地图SDK报以下错误: java.lang.UnsatisfiedLinkError: Native method not found: com.baidu ...

  4. Cross Platform Note: STD C++ Preprocessor directives & pre-defined macros

    ref: http://www.cplusplus.com/doc/tutorial/preprocessor/ concolusion: directives: #define #undef #in ...

  5. 译:Spring框架参考文档之IoC容器(未完成)

    6. IoC容器 6.1 Spring IoC容器和bean介绍 这一章节介绍了Spring框架的控制反转(IoC)实现的原理.IoC也被称作依赖注入(DI).It is a process wher ...

  6. C-Language Functions

    转自:https://www.postgresql.org/docs/9.6/xfunc-c.html 可以作为学习基于c编写pg extension 的资料 36.9. C-Language Fun ...

  7. 关于C#你应该知道的2000件事

    原文 关于C#你应该知道的2000件事 下面列出了迄今为止你应该了解的关于C#博客的2000件事的所有帖子. 帖子总数= 1,219 大会 #11 -检查IL使用程序Ildasm.exe d #179 ...

  8. Android内核的编译和调试

    本文博客地址:http://blog.csdn.net/qq1084283172/article/details/70500488 一.Android内核源码的选择 Android手机设备内核源码的调 ...

  9. iPhone:4.7 5.5 4 3.5 对应的各个设备屏幕尺寸对应的像素及App上线信息

    Shared App Information You can access these properties from the App Details page in the App Informat ...

随机推荐

  1. windows下的gvim和emmet 下载和安装 + "omnifunc is not set" solution?

    注意几个地方: 引导键是ctrl-y, 其他就是实际的操作键了, 如: n下一个插入点, N是上一个插入点(不是p), ctrl-y + i是自动为图片添加宽度和高度尺寸, 要点是要把光标移动到 im ...

  2. 一种斐波那契博弈(Fibonacci Nim)

    事实上我也不知道这算是哪个类型的博弈 是在复习$NOIP$初赛的时候看到的一个挺有趣的博弈 所以就写出来分享一下 $upd \ on \ 2018.10.12$忽然发现这个其实就是$Fibonacci ...

  3. [BZOJ1370][Baltic2003]Gang团伙 并查集+拆点

    Description 在某城市里住着n个人,任何两个认识的人不是朋友就是敌人,而且满足: 1. 我朋友的朋友是我的朋友: 2. 我敌人的敌人是我的朋友: 所有是朋友的人组成一个团伙.告诉你关于这n个 ...

  4. C#学习笔记(一):C#简介

    计算机语言计算机语言是指用于人与计算机之间通讯的语言机器码——汇编语言——高级语言(面向过程(线性).面向对象(类).面向组件(Unity)) 一.计算机语言发展趋势1.简单:代码生成逻辑2.面向人类 ...

  5. Hadoop MapReduce编程 API入门系列之Crime数据分析(二十五)(未完)

    不多说,直接上代码. 一共12列,我们只需提取有用的列:第二列(犯罪类型).第四列(一周的哪一天).第五列(具体时间)和第七列(犯罪场所). 思路分析 基于项目的需求,我们通过以下几步完成: 1.首先 ...

  6. spoj TBATTLE 质因数分解+二分

    题目链接:点击传送 TBATTLE - Thor vs Frost Giants #number-theory #sliding-window-1 Thor is caught up in a fie ...

  7. codeforces 351 div2 C. Bear and Colors 暴力

    C. Bear and Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. yaml 文件保存

    with open(mpath, "w") as f: yaml.safe_dump(yaml_dict,f,encoding='utf-8', allow_unicode=Tru ...

  9. shell 脚本拼接

    var21=`echo $vvar|awk -F ',' '{print $1}'` echo $var21 var31=`echo $var21|awk -F ':' '{print $2}'` e ...

  10. Node.js结合Selenium做Web自动化测试

    发现腾讯课堂上有个node.js结合Selenium做Web自动化测试的教学视频, 听来感觉不错,一来老师讲的还不错,二来node.js这门语言会越来越热,学会总没什么坏处,三来发现CukeTest这 ...