Casting Delphi 2009/2010 string literals to PAnsiChar

前端 未结 4 1470
一向
一向 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:58

    For type-inferred constants (only initializable from literals) the compiler changes the actual text at compile-time, rather than at runtime. That means it knows whether or not the conversion loses data, so it doesn't need to warn you if it doesn't.

提交回复
热议问题