Casting Delphi 2009/2010 string literals to PAnsiChar

前端 未结 4 1480
一向
一向 2021-02-11 01:33

So the question is whether or not string literals (or const strings) in Delphi 2009/2010 can be directly cast as PAnsiChar\'s or do they need an additional cast to AnsiString fi

4条回答
  •  余生分开走
    2021-02-11 01:53

    Constants, including string literals, are untyped by default, and the compiler will fit them into whatever format works in the context you're using them in. As long as there are no non-ANSI characters in your string literal, the compiler won't have any trouble generating the string as ANSI instead of Unicode in this situation.

提交回复
热议问题