Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. hello i have a question about incompatible pointer type [modified]

hello i have a question about incompatible pointer type [modified]

Scheduled Pinned Locked Moved Visual Basic
questionc++delphidata-structureshelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lxlenovostar
    wrote on last edited by
    #1

    i have this code:

    type
    Symbol = string[8];
    SymTab = array[1..1000] of Symbol;
    TabPtr = ^SymTab;

    var
    ST: array[1..MaxEntry] of Symbol;
    SType: array[1..MaxEntry] of char;

    132 function Lookup(T: TabPtr; s: string; n: integer): integer;
    133 var
    134 i: integer;
    135 found: Boolean;
    136 begin
    137 found := false;
    138 i := n;
    139 while (i > n) and not found do
    140 if s = T^[i] then
    141 found := true
    142 else
    143 dec(i);
    144 Lookup := i;
    145 end;

    152 function InTable(n: Symbol): Boolean;
    153 begin
    154 InTable := Lookup(@ST, n, MaxEntry) <> 0;
    155 end;

    when i complier with gpc , it will print this:Tiny10.pas: In function `InTable':
    <b>Tiny10.pas:154: error: passing arg 1 of `Lookup' from incompatible pointer type
    Tiny10.pas:132: error: routine declaration</b>

    can you tell me why? actually,i just know C++, i learn pascal for i read a book which use it.
    thank you

    modified on Tuesday, December 7, 2010 3:53 AM

    L _ 2 Replies Last reply
    0
    • L lxlenovostar

      i have this code:

      type
      Symbol = string[8];
      SymTab = array[1..1000] of Symbol;
      TabPtr = ^SymTab;

      var
      ST: array[1..MaxEntry] of Symbol;
      SType: array[1..MaxEntry] of char;

      132 function Lookup(T: TabPtr; s: string; n: integer): integer;
      133 var
      134 i: integer;
      135 found: Boolean;
      136 begin
      137 found := false;
      138 i := n;
      139 while (i > n) and not found do
      140 if s = T^[i] then
      141 found := true
      142 else
      143 dec(i);
      144 Lookup := i;
      145 end;

      152 function InTable(n: Symbol): Boolean;
      153 begin
      154 InTable := Lookup(@ST, n, MaxEntry) <> 0;
      155 end;

      when i complier with gpc , it will print this:Tiny10.pas: In function `InTable':
      <b>Tiny10.pas:154: error: passing arg 1 of `Lookup' from incompatible pointer type
      Tiny10.pas:132: error: routine declaration</b>

      can you tell me why? actually,i just know C++, i learn pascal for i read a book which use it.
      thank you

      modified on Tuesday, December 7, 2010 3:53 AM

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, 1. this is not the right forum for this. Your code might be Pascal, it certainly isn't Visual Basic. 2. I don't know the answer, I would however try again without the '@' in line 154 3. yes, I use line numbers to my advantage, and so should you; tell your IDE to show line numbers, look at such details when the compiler or run-time reports problems, and when you post, indicate which line has what line number of interest. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, and update CP Vanity to V2.0 if you haven't already.

      1 Reply Last reply
      0
      • L lxlenovostar

        i have this code:

        type
        Symbol = string[8];
        SymTab = array[1..1000] of Symbol;
        TabPtr = ^SymTab;

        var
        ST: array[1..MaxEntry] of Symbol;
        SType: array[1..MaxEntry] of char;

        132 function Lookup(T: TabPtr; s: string; n: integer): integer;
        133 var
        134 i: integer;
        135 found: Boolean;
        136 begin
        137 found := false;
        138 i := n;
        139 while (i > n) and not found do
        140 if s = T^[i] then
        141 found := true
        142 else
        143 dec(i);
        144 Lookup := i;
        145 end;

        152 function InTable(n: Symbol): Boolean;
        153 begin
        154 InTable := Lookup(@ST, n, MaxEntry) <> 0;
        155 end;

        when i complier with gpc , it will print this:Tiny10.pas: In function `InTable':
        <b>Tiny10.pas:154: error: passing arg 1 of `Lookup' from incompatible pointer type
        Tiny10.pas:132: error: routine declaration</b>

        can you tell me why? actually,i just know C++, i learn pascal for i read a book which use it.
        thank you

        modified on Tuesday, December 7, 2010 3:53 AM

        _ Offline
        _ Offline
        _Erik_
        wrote on last edited by
        #3

        This is Pascal, not VB. Maybe the Delphi forum would have been better for this question. Anyway: ST is declared as array[1..MaxEntry] of Symbol TabPtr is declared as ^SymTab (pointer to SymTab) T parameter in Lookup function is declared as TabPtr -- ^SymTab So, declare ST as SymTab and it should work.

        L 1 Reply Last reply
        0
        • _ _Erik_

          This is Pascal, not VB. Maybe the Delphi forum would have been better for this question. Anyway: ST is declared as array[1..MaxEntry] of Symbol TabPtr is declared as ^SymTab (pointer to SymTab) T parameter in Lookup function is declared as TabPtr -- ^SymTab So, declare ST as SymTab and it should work.

          L Offline
          L Offline
          lxlenovostar
          wrote on last edited by
          #4

          thank you.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups