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. C++中find()函数和rfind()函数的用法

    本文转载自http://blog.csdn.net/youxin2012/article/details/9162415 string中 find()的应用  (rfind() 类似,只是从反向查找) ...

  2. HDU1143 (递推)题解

    Tri Tiling Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total ...

  3. swift设计模式学习 - 代理模式

    移动端访问不佳,请访问我的个人博客 设计模式学习的demo地址,欢迎大家学习交流 代理模式 代理模式为其他对象提供一种代理以控制对这个对象的访问,在某些情况下,一个对象不适合或者不能直接引用另一个对象 ...

  4. 如何在Twitter开发者平台上注册自己的应用

    1.打开twitter的官网https://dev.twitter.com,如果还没有注册账号的,需要注册账号,已经注册账号的,请先登录:2.选择其中的My apps,如下图: 3.进去界面,选择Cr ...

  5. Java课程设计—拿火柴小游戏

    这是我的Java课程设计,做的是拿火柴小游戏.要求是人机互拿火柴,拿到最后一根火柴者赢.最主要的就是处理好多线程,其他的就是添加组件啥的,那个不难,我就给出以下多线程的代码吧. import java ...

  6. 【Ctsc2011】幸福路径

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2306 给定一张有向图,每个点有权值,蚂蚁从某个节点出发,初始体力值为$1$,每走一条边$体 ...

  7. select 操作

    一:JavaScript 1:拿到select对象: var myselect=document.getElementById(“test”); 2:拿到选中项的索引:var index=mysele ...

  8. Android之动态改变控件大小

    利用getLayoutParams()方法和setLayoutParams()方法.三步曲:1.首先利用getLayoutParams()方法,获取控件的LayoutParams.eg:LayoutP ...

  9. Java-Java面向对象程序设计

    2017-10-09 17:23:52 在面向对象技术中,将客观世界中的一个事物作为一个对象来考虑,比如有个张先生,他就是一个对象.每个对象都有自己的属性和行为.张先生的属性根据需要有姓名.性别.身高 ...

  10. Creating SSL Certificates for CRM Test Environment

    不必找第三方去申请证书了, Windows Server 自己也可以作为一个CA的. When working on a CRM Test environment there are many sce ...