Please note that PChar depends on the mode switches. In mode DelphiUnicode or if modeswitch UnicodeStrings is set the type PChar will be an alias to PWideChar just like in Delphi. Otherwise it's an alias to PAnsiChar (and that is also what you'd use in Delphi to deal with non-Unicode zero terminated characters).
I personally consider it as defensive programming to use either PWideChar or PAnsiChar if my code depends on that instead of PChar as the default might change in the future.
I appreciate that information. Either I use no mode at all, which means I use the default mode - i.e, FPC, or specifically OBJFPC, either with explicit enabling/disabling of other features. There are some "features" I want to ensure I do _not_ enable and some that cannot be turned off I will never use, except possibly in throw-away code.
I find having to explicitly use pansichar instead of pchar a disgrace. A compiler "designer" laid the idea of making pchar the same as pwidechar and, now to avoid that atrocity, programmers have to play it "safe" and use pansichar. A programmer shouldn't have to do that kind of defensive programming. The compiler should do what the programmer specified, not something else.
I have very strong feelings about the way Borland/Codegear/Embarcadero have contaminated the Pascal language with decisions that are nothing short of atrocities. Treating pchar as pwidechar is one of them.
At the very least, there should have been an option, compiler switch, to enable/disable that "feature" and the default should be how it worked in the past not some new way that breaks just about every piece of code written before it.
My way of being defensive is, the last time Borland/Codegear/Embarcadero saw a dime from me is when I purchased Delphi 5 and, considering Delphi's market share trend, it seems I am not the only one with that method. I don't see them getting any money from me in the future either, I haven't even bothered to get their free/community version, their product has become something I don't want, even for free.
If they had not made pchar a synonym for pwidechar, or if they had given a way to turn that disgrace off, most likely I would have purchased the first version of 64bit Delphi (I don't remember which one it was.) and, I would be a customer today. For 64bit apps, I had to use C/C++ instead. I really dislike C but, I have to give credit to MS for their VS debugger. I still use C/C++ because of it. I wanted to say something positive in this post for a change. Now that I am in positive mode ...
I can also say that I am really pleased with FPC. It does have its rough edges here and there but, it gets the job done and so far, when I tell it something is a pchar, it's always treated it as a pchar. Good compiler!.
I know you are part of the team that works on FPC, therefore have my heartfelt thank you for making FPC possible and what it is.