在一个由C语言写的DLL中定义了一个回调函数,其中一个参数为Char **buf;
由此我定义了一个如下类型type pPChar = ^PChar(如果直接定义变量为buf:^PChar,无法编译通过);然后定义如下变量buf : pPChar;可是我在编译的时候,编译器认为 Char 等价于 pPChar,这是怎么回事?望高手解答。

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var a:pointer ;
    b:Pointer;
    begin
      a := @button1;
      Showmessage(TButton(a^).Caption);
      b := @a;//b为a的指针
      Showmessage(TButton(Pointer(b^)^).Caption);
    end;
      

  2.   

    谢谢你的回答,这样用我也知道,关键是我需要定义回调函数中的一个参数类型,这个类型就是指向char类型的指针的指针。
      

  3.   

    type CharPt = ^Char;
    type PtOfCharPt = ^CharPt;
    var p : PtOfCharPt;
      

  4.   

    晕哦,兄弟,我就是这样做的啊,你可能没有看清楚我上面写的,但是编译器认为这样PtOfCharPt 等价于 Char。
    再次谢谢。呵呵:)
      

  5.   

    procedure TForm1.Button1Click(Sender: TObject);
    Type
      PmChar=^Char;
      pPmChar = ^pmChar;
    var
      C:Char;
      Pm:PmChar;
      ppm:pPmChar;
    begin
      C:='A';
      //pPm:=c;//<--编译通不过的,谁说相等了
      Pm:=@C;
      PPM:=@PM;
      SHowMessage(PPM^^);
    end;
      

  6.   

    Function (var VP : PChar ....)
    就行了
      

  7.   

    type
      TSK = procedure (var P : PChar);stdcall;var
      P : PChar;
      SK : TSK;
    begin
      SK := NIL;
      Getmem(P,10);
      FillChar(P,10,'A');
      SK(P);  <-跟踪到这一行,然后按Alt+C 看esp的值,就知道了,ESP保存的是P变量的地址,
      FreeMem(P);
    end;
    以上程序不能运行,只作调试看代码用
      

  8.   

    这就是我的回调函数:之前定义了ppChar = ^PChar
    function PdcPtlCallBackFunc(cType: Integer; dwCode: LongInt; dwDataSize: LongWord;
                                pData:PChar; Buf: pPChar; UserData: LongWord): Integer; cdecl;在函数中我又定义了一个变量(t: PChar),带参数的时候把Buf带进去了(本来该带t),结果编译器报错说(不兼容的类型 PChar 与 Char).你们说这是怎么回事嘛。难道是PChar的原因?
      

  9.   

    楼主,听我的,就用
    var P : PChar
    就行了!
      

  10.   

    [Error] CommonUnit.pas(357): Incompatible types: 'PChar' and 'Char'
    [Fatal Error] EDCS7960.dpr(17): Could not compile used unit 'CommonUnit.pas'
    这就是编译时报的错误信息
      

  11.   

    function PdcPtlCallBackFunc(cType: Integer; dwCode: LongInt; dwDataSize: LongWord;
                                pData:PChar; Buf: pPChar; UserData: LongWord): Integer; cdecl;
    begin
    ... 
      case cType of
        10: //发送数据
          begin
            if (GetInstance_cType(gHComm) = 1) then
              begin
                //以TCP方式发送
                SendSocketDataA(TcpHandle, dwDataSize, Buf(本应为pData,不小心写错了), 0); 
                ....
     end
            else
              begin
                //port_write232port(GetInstance_232Handle(pComm), datasize, pdata);
                SendRS232Data(RS232Handle, buf, dwDataSize);
              end;
          end;
        11:
          ...
      end;
    ....
    end;结果编译时就发生上面那贴的错误