What's wrong with this function? lazarus / 61-Beginners ---------------------------------------------------------------------- 1q5xaaqz · 2022-03-03 16:22 It was translated from C header to use with Pascal: function _convertargs(count:Plongint; start:Pchar; hInstance:HINSTANCE):PPchar;cdecl;external; The compiler will always error about type identifier expected. ---------------------------------------------------------------------- Remy Lebeau · 2022-03-03 16:25 Quote from: 1q5xaaqz on March 03, 2022, 05:22:35 pmIt was translated from C header to use with Pascal What does the original C declaration look like? Quote from: 1q5xaaqz on March 03, 2022, 05:22:35 pmfunction _convertargs(count:Plongint; start:Pchar; hInstance:HINSTANCE):PPchar;cdecl;external; The compiler will always error about type identifier expected. Which identifier exactly is it complaining about? ---------------------------------------------------------------------- 1q5xaaqz · 2022-03-03 16:29 Quote from: Remy Lebeau on March 03, 2022, 05:25:08 pm What does the original C declaration look like? Which identifier exactly is it complaining about? char ** _convertargs(int *count, char *start, HINSTANCE hInstance); The compiler doesn't tell which identifier. ---------------------------------------------------------------------- Remy Lebeau · 2022-03-03 16:31 Quote from: 1q5xaaqz on March 03, 2022, 05:29:31 pmThe compiler doesn't tell which identifier. I would be very shocked if that were true. ---------------------------------------------------------------------- 440bx · 2022-03-03 16:37 Quote from: 1q5xaaqz on March 03, 2022, 05:22:35 pmfunction _convertargs(count:Plongint; start:Pchar; hInstance:HINSTANCE):PPchar;cdecl;external; Sometimes what the compiler is complaining about is not obvious but, formatting the definition using a separate line for each parameter often makes the error obvious.  Using your definition, format it this way: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function _convertargs( count:Plongint; start:Pchar; hInstance:HINSTANCE) : PPchar; cdecl; external; I just noticed... if you declare a function to be "external" (as you're doing above), the compiler (not to mention the linker) would probably like to know the external target (i.e, name) HTH. ---------------------------------------------------------------------- Thaddy · 2022-03-03 16:37 char ** means a pointer to an array of Pchars, which are Char *. The terminator is a double zero #0#0. ---------------------------------------------------------------------- 1q5xaaqz · 2022-03-03 16:39 Quote from: Remy Lebeau on March 03, 2022, 05:31:24 pmQuote from: 1q5xaaqz on March 03, 2022, 05:29:31 pmThe compiler doesn't tell which identifier. I would be very shocked if that were true. test.pp(734,74) Error: Type identifier expected test.pp(736,1) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Error: C:\FPC\3.2.2\bin\i386-Win32\ppc386.exe returned an error exitcode Commenting out the function above (at line 734) and the error also gone. ---------------------------------------------------------------------- tetrastes · 2022-03-03 16:40 function _convertargs(count:Plongint; start:Pchar; hInstance:HINSTANCE):PPchar;cdecl;external; Pascal is case insensitive. ---------------------------------------------------------------------- 1q5xaaqz · 2022-03-03 16:42 Quote from: 440bx on March 03, 2022, 05:37:16 pmI just noticed... if you declare a function to be "external" (as you're doing above), the compiler (not to mention the linker) would probably like to know the external target (i.e, name) HTH. function _convertargs(count:Plongint; start:Pchar; hInstance:HINSTANCE):PPchar;cdecl;external 'test.dll' name '_convertargs'; The same error as above. ---------------------------------------------------------------------- 1q5xaaqz · 2022-03-03 16:43 Quote from: tetrastes on March 03, 2022, 05:40:58 pmfunction _convertargs(count:Plongint; start:Pchar; hInstance:HINSTANCE):PPchar;cdecl;external; Pascal is case insensitive.  function _convertargs(count:Plongint; start:Pchar; hInstance_:HINSTANCE):PPchar;cdecl;external; Appended an underscore to the identifier name, same error as the above. ---------------------------------------------------------------------- 440bx · 2022-03-03 16:52 Quote from: 1q5xaaqz on March 03, 2022, 05:43:42 pmfunction _convertargs(count:Plongint; start:Pchar; hInstance_:HINSTANCE):PPchar;cdecl;external; As the compiler error states "HINSTANCE", in that context, is not a data type name, it is a parameter name and a parameter name is not a data type name.  Change HINSTANCE to HMODULE (which is what it really is anyway) and your definition will compile. HTH. ---------------------------------------------------------------------- tetrastes · 2022-03-03 16:55 Well... When in Lazarus I place mouse to HINSTANCE, I get the following hint: Function HINSTANCE : TFPResourceHMODULE; C:\lazarus\fpc\3.0.4\source\rtl\inc\resh.inc(56,10)  unit System Win32 API compatible Resource functions (Source) ---------------------------------------------------------------------- 1q5xaaqz · 2022-03-03 16:59 Quote from: 440bx on March 03, 2022, 05:52:27 pmQuote from: 1q5xaaqz on March 03, 2022, 05:43:42 pmfunction _convertargs(count:Plongint; start:Pchar; hInstance_:HINSTANCE):PPchar;cdecl;external; As the compiler error states "HINSTANCE", in that context, is not a data type name, it is a parameter name and a parameter name is not a data type name.  Change HINSTANCE to HMODULE (which is what it really is anyway) and your definition will compile. HTH. Just find out HINSTANCE and HMODULE is the same. Thank you. https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data- types ---------------------------------------------------------------------- 1q5xaaqz · 2022-03-03 17:01 Quote from: tetrastes on March 03, 2022, 05:55:41 pmWell... When in Lazarus I place mouse to HINSTANCE, I get the following hint: Function HINSTANCE : TFPResourceHMODULE; C:\lazarus\fpc\3.0.4\source\rtl\inc\resh.inc(56,10)  unit System Win32 API compatible Resource functions (Source) I have no idea why the compiler thinks like this. I have other code with a WinMain function with HINSTANCE involved. It compiles just fine. function WinMain (hInst : HINSTANCE; hPInst : HINSTANCE; cmdLine : PSTR; cmdShow : integer):integer; ---------------------------------------------------------------------- 1q5xaaqz · 2022-03-03 17:04 Maybe the RTL System unit has higher priority than the Windows unit so that definition was picked up. Anyway, changing HINSTANCE to HMODULE solved the problem. Thanks everyone. ---------------------------------------------------------------------- 440bx · 2022-03-03 17:15 Quote from: 1q5xaaqz on March 03, 2022, 05:59:08 pmJust find out HINSTANCE and HMODULE is the same. Thank you. https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data- types keep in mind that, as the MS documentation states, while HINSTANCE and HMODULE are both HANDLE(s), they represent very different things. In Win32, the sort of, equivalent to HINSTANCE would be an HPROCESS.  "sort of" because, they are used differently.  Strictly speaking, there is no strict equivalent to HINSTANCE in Win32.  HINSTANCE is a Win16 legacy concept that isn't represented in Win32.